[LLVMbugs] [Bug 5807] New: likely wrong code bug

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 16 09:36:16 PST 2009


           Summary: likely wrong code bug
           Product: new-bugs
           Version: trunk
          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

In the C code below, x is incremented each time foo() is called.  In the LLVM
code it is not.

regehr at john-home:~$ clang -Os llvm-bad-loop.c -S -emit-llvm -o -
; ModuleID = 'llvm-bad-loop.c'
target datalayout =
target triple = "i386-pc-linux-gnu"

@y = common global i32 0, align 4                 ; <i32*> [#uses=1]

define i32 @foo(i32 %x) nounwind readnone optsize {
  %shr = ashr i32 %x, 7                           ; <i32> [#uses=1]
  ret i32 %shr

define i32 @main() noreturn nounwind optsize {
  br label %while.body

while.body:                                       ; preds = %entry, %while.body
  volatile store i32 undef, i32* @y
  br label %while.body
regehr at john-home:~$ cat llvm-bad-loop.c 
int foo (int x)
  return x>>7;

volatile int y;

int main (void)
  unsigned int x;
  while (1) {
    y = foo (x++);
regehr at john-home:~$ clang -v
clang version 1.1 (trunk 91411)
Target: i386-pc-linux-gnu
Thread model: posix

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