[LLVMbugs] [Bug 18304] New: LLVM optimizes away local variables making them alias

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Dec 21 08:50:49 PST 2013


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

            Bug ID: 18304
           Summary: LLVM optimizes away local variables making them alias
           Product: new-bugs
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: uzytkownik2 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11771
  --> http://llvm.org/bugs/attachment.cgi?id=11771&action=edit
Test case in C++

The LLVM opt -O2 optimizes the:

define i32 @main() #2 {
  %1 = alloca i32, align 4
  %ptr1 = alloca i32, align 4
  %ptr2 = alloca i32, align 4
  store i32 0, i32* %1
  call void @_Z4testPi(i32* %ptr2)
  %2 = load i32* %ptr2, align 4
  store i32 %2, i32* %ptr1, align 4
  call void @_Z4testPi(i32* %ptr1)
  ret i32 0
}

into:

define i32 @main() #2 {
  %ptr1 = alloca i32, align 4
  call void @_Z4testPi(i32* %ptr1)
  call void @_Z4testPi(i32* %ptr1)
  ret i32 0
}

The problem is that ptr1 and 'new' ptr2 alias in second case while they did not
in first case. As ptr2 is still formally alive (at least in case of C++) the
test might access it. So the attached testcase produce:

clang++ 3.3/gcc 4.8 -O3:
0
2

clang++ 3.3 -O2:
0
AAA
1

(I've observed it while playing with how clang handles aliases)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131221/1705a1de/attachment.html>


More information about the llvm-bugs mailing list