[LLVMbugs] [Bug 2182] New: wrong code emitted for volatile accesses

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Mar 30 22:09:00 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2182

           Summary: wrong code emitted for volatile accesses
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


This is for:

regehr at home-linux:~/volatile/tmp0$ llvm-gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure
--prefix=/home/regehr/llvm-gcc4.2-2.2.source/obj/../install
--enable-llvm=/home/regehr/llvm-2.2 --enable-languages=c,c++
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5546) (LLVM build)


This code:

volatile int x;
void loop_2 (void) {
  int i;
  for (i=0; i<4; i++) {
    x = x+3;
  }
}

Compiled like this:

llvm-gcc -O2 -S foo.c

Turns into:

loop_2:
        pushl   %ebp
        movl    %esp, %ebp
        movl    x, %eax
        leal    3(%eax), %ecx
        movl    %ecx, x
        leal    6(%eax), %ecx
        movl    %ecx, x
        leal    9(%eax), %ecx
        movl    %ecx, x
        addl    $12, %eax
        movl    %eax, x
        popl    %ebp
        ret

x must be loaded and stored at each loop iteration.  The loads are incorrectly
being optimized away.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list