Bug 602359 - miscompilation on ppc for inline-asm with "g" constraints
miscompilation on ppc for inline-asm with "g" constraints
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc (Show other bugs)
6.0
powerpc Linux
high Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
Michal Nowak
:
Depends On:
Blocks: 596933 640321
  Show dependency treegraph
 
Reported: 2010-06-09 13:07 EDT by Stan Cox
Modified: 2013-03-07 21:10 EST (History)
6 users (show)

See Also:
Fixed In Version: gcc-4.4.4-9.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 640321 (view as bug list)
Environment:
Last Closed: 2010-11-10 15:24:58 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
preprocessed systemtap module cache.cxx (967.16 KB, text/plain)
2010-06-09 15:56 EDT, Stan Cox
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 44492 None None None Never

  None (edit)
Description Stan Cox 2010-06-09 13:07:18 EDT
The following is generated with 
gcc version 4.4.4 20100518 (Red Hat ##### 4.4.4-4).  

Is 'g' below being too permissive or is the __asm__
assuming too much with that general of a constraint?


##### left side problem
##### *(r28+36Is 'g' being too permissive here or is the __asm__
assuming too much with that general of a constraint?0) == s.hash_path.c_str()
##### *(r1+168) == module_src_path.c_str()
##### but later r28 is loaded into 4 and passed to copy_file without 360 offset

##### right side okay
##### *(r31+360) == s.hash_path.c_str()
##### *(r1+168) == module_src_path.c_str()
##### r31+360 is reloaded into r27 then into r4

##### The difference between the left and right is "g" changed to "ro" in
##### __asm__ below.
               nop /* 168(1) 360(28) */      |            nop /* 168(1) 360(31) */
 9851                    # 0 "" 2          <
 9852                   #NO_APP                  <
 9853                   .LBE4751:          <

  if (file_exists (module_src_path + ".sgn"))
    copy_file(module_src_path + ".sgn", s.hash_path + ".sgn", verbose);

 9855 2ddc 7FA3EB78         mr 3,29           |       9852 2dd8 3B7F0168     addi 27,31,360
 9856 2de0 7F84E378         mr 4,28           |       9853 2ddc 7FA3EB78     mr 3,29
 9857 2de4 7F65DB78         mr 5,27           |       9854 2de0 7F64DB78     mr 4,27

The source for the nop is: 
 __asm__ volatile ("2:\n" "\tnop " "/* " "%0 %1" " */" :: "g"(arg1), "g"(arg2));

The rtl for the nop is below.  It assumes the pre_modify will be done
for later reuse.  

(insn:TI 238 1018 241 ../src/cache.cxx:73 (asm_operands/v ("2:
        nop /* %0 %1 */") ("") 0 [
            (mem/s/f/c:DI (plus:DI (reg/f:DI 1 1)
                    (const_int 168 [0xa8])) [7 module_src_path._M_dataplus._M_p+0 S8 A64])
            (mem/s/f:DI (pre_modify:DI (reg/f:DI 28 28 [orig:149 D.40808 ] [149])
                    (plus:DI (reg/f:DI 28 28 [orig:149 D.40808 ] [149])
                        (const_int 360 [0x168]))) [7 <variable>.hash_path._M_dataplus._M_p+0 S8 A64])
        ]
         [
            (asm_input:DI ("rm") (null):0)
            (asm_input:DI ("rm") (null):0)
        ]
         [] ../src/cache.cxx:96) -1 (expr_list:REG_INC (reg/f:DI 28 28 [orig:149 D.40808 ] [149])
        (nil)))
Comment 2 RHEL Product and Program Management 2010-06-09 13:32:55 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.
Comment 3 Jakub Jelinek 2010-06-09 15:28:55 EDT
Please provide preprocessed source and say what g++ options were used.
Comment 4 Stan Cox 2010-06-09 15:56:21 EDT
Created attachment 422679 [details]
preprocessed systemtap module cache.cxx
Comment 5 Stan Cox 2010-06-09 15:58:03 EDT
g++ -Wall -Werror -g -O2 -Werror -fstack-protector-all  -c /tmp/cache.ii
In function add_script_to_cache at __asm__ volatile ("2:\n" "\tnop "
Comment 6 Jakub Jelinek 2010-06-10 07:51:05 EDT
So far there seems to be a heated debate about this.
Comment 7 Jakub Jelinek 2010-06-24 15:42:34 EDT
A variant that only allows side-effects if there is < or > in constraint string in inline-asm has been approved upstream, will be backported.
Comment 8 Frank Ch. Eigler 2010-06-24 15:50:27 EDT
FWIW, systemtap works around this in the current rhel6 + future fedoras by
using the assembly constraint string "ron" instead of "g" on all platforms.
Comment 10 Jakub Jelinek 2010-06-25 06:02:19 EDT
This has been approved upstream, committed there and backported.
Comment 11 Frank Ch. Eigler 2010-06-29 11:24:28 EDT
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44492 appears to contain a reproducer.
Comment 14 releng-rhel@redhat.com 2010-11-10 15:24:58 EST
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

Note You need to log in before you can comment on or make changes to this bug.