diff options
author | James Molloy <james.molloy@arm.com> | 2016-01-07 13:33:28 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2016-01-07 13:33:28 +0000 |
commit | 6a8908e97960a3929876e52fe57a46982230bb03 (patch) | |
tree | b1ea2f3a93f4277e952817915d976b7a29d4ee4d /lib/Analysis/GlobalsModRef.cpp | |
parent | 699e85dc452a2d54e9241ebe8ebbc48827b931c8 (diff) |
[GlobalsAA] Partially back out r248576
See PR25822 for a more full summary, but we were conflating the concepts of "capture" and "escape". We were proving nocapture and using that proof to infer noescape, which is not true. Escaped-ness is a function-local property - as soon as a value is used in a call argument it escapes. Capturedness is a related but distinct property. It implies a *temporally limited* escape. Consider:
static int a;
int b;
int g(int * nocapture arg);
int f() {
a = 2; // Even though a escapes to g, it is not captured so can be treated as non-escaping here.
g(&a); // But here it must be treated as escaping.
g(&b); // Now that g(&a) has returned we know it was not captured so we can treat it as non-escaping again.
}
The original commit did not sufficiently understand this nuance and so caused PR25822 and PR26046.
r248576 included both a performance improvement (which has been backed out) and a related conformance fix (which has been kept along with its testcase).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257058 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GlobalsModRef.cpp')
-rw-r--r-- | lib/Analysis/GlobalsModRef.cpp | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/lib/Analysis/GlobalsModRef.cpp b/lib/Analysis/GlobalsModRef.cpp index 249f3954d55..1babb822074 100644 --- a/lib/Analysis/GlobalsModRef.cpp +++ b/lib/Analysis/GlobalsModRef.cpp @@ -358,21 +358,6 @@ bool GlobalsAAResult::AnalyzeUsesOfPointer(Value *V, if (CS.isArgOperand(&U) && isFreeCall(I, &TLI)) { if (Writers) Writers->insert(CS->getParent()->getParent()); - } else if (CS.doesNotCapture(CS.getDataOperandNo(&U))) { - Function *ParentF = CS->getParent()->getParent(); - // A nocapture argument may be read from or written to, but does not - // escape unless the call can somehow recurse. - // - // nocapture "indicates that the callee does not make any copies of - // the pointer that outlive itself". Therefore if we directly or - // indirectly recurse, we must treat the pointer as escaping. - if (FunctionToSCCMap[ParentF] == - FunctionToSCCMap[CS.getCalledFunction()]) - return true; - if (Readers) - Readers->insert(ParentF); - if (Writers) - Writers->insert(ParentF); } else { return true; // Argument of an unknown call. } |