llvm.org GIT mirror llvm / 5445333
Don't infer whether a value is captured in the current function from the 'nocapture' attribute. The nocapture attribute only specifies that no copies are made that outlive the function. This isn't the same as there being no copies at all. This fixes PR14045. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167381 91177308-0d34-0410-b5e6-96231b3b80d8 Richard Osborne 8 years ago
2 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
5757 // then it has not escaped before entering the function. Check if it escapes
5858 // inside the function.
5959 if (const Argument *A = dyn_cast(V))
60 if (A->hasByValAttr() || A->hasNoAliasAttr()) {
61 // Don't bother analyzing arguments already known not to escape.
62 if (A->hasNoCaptureAttr())
63 return true;
60 if (A->hasByValAttr() || A->hasNoAliasAttr())
61 // Note even if the argument is marked nocapture we still need to check
62 // for copies made inside the function. The nocapture attribute only
63 // specifies that there are no copies made that outlive the function.
6464 return !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true);
65 }
65
6666 return false;
6767 }
6868
1212 ret i32 %c
1313 }
1414
15 declare void @test3(i32** %p, i32* %q) nounwind
16
17 define i32 @test4(i32* noalias nocapture %p) nounwind {
18 ; CHECK: call void @test3
19 ; CHECK: store i32 0, i32* %p
20 ; CHECK: store i32 1, i32* %x
21 ; CHECK: %y = load i32* %p
22 ; CHECK: ret i32 %y
23 entry:
24 %q = alloca i32*
25 ; Here test3 might store %p to %q. This doesn't violate %p's nocapture
26 ; attribute since the copy doesn't outlive the function.
27 call void @test3(i32** %q, i32* %p) nounwind
28 store i32 0, i32* %p
29 %x = load i32** %q
30 ; This store might write to %p and so we can't eliminate the subsequent
31 ; load
32 store i32 1, i32* %x
33 %y = load i32* %p
34 ret i32 %y
35 }