[LLVMbugs] [Bug 14045] New: Miscompilation of load from nocapture argument that is indirectly copied to a local alloca

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 9 02:24:12 PDT 2012


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

             Bug #: 14045
           Summary: Miscompilation of load from nocapture argument that is
                    indirectly copied to a local alloca
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Global Analyses
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: richard at xmos.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Regarding the nocapture attribute the language ref says: "the callee does not
make any copies of the pointer that outlive the callee itself". Therefore it
should be OK for the callee to make a copy of the pointer that doesn't outlive
the call. Consider the following example:

1  declare void @g(i32** %p, i32* %q) nounwind
2 
3  define i32 @f(i32* noalias nocapture %p) nounwind {
4  entry:
5    %q = alloca i32*
6    call void @g(i32** %q, i32* %p) nounwind
7    store i32 0, i32* %p
8    %0 = load i32** %q
9    store i32 1, i32* %0
10   %1 = load i32* %p
11   ret i32 %1
12 }

The store on line 9 might write to %p since g() might store the value of its
second argument to its first argument. While this creates a copy of %p it
doesn't violate the nocapture attribute as the copy wouldn't outlive the
function.

However if I run the following example through opt -basicaa -gvn I get the
following:

declare void @g(i32**, i32*) nounwind

define i32 @f(i32* noalias nocapture %p) nounwind {
entry:
  %q = alloca i32*
  call void @g(i32** %q, i32* %p) nounwind
  store i32 0, i32* %p
  %0 = load i32** %q
  store i32 1, i32* %0
  ret i32 0
}

The return has been optimized to a return 0, indicating that basic alias
analysis has incorrectly concluded that there is no possible alias between the
load on line 10 and and the store on line 9.

-- 
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