diff options
author | Owen Anderson <resistor@mac.com> | 2009-02-04 05:16:46 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-02-04 05:16:46 +0000 |
commit | fe9388ccb4d2449e8e6a62053479a0ba74ae0b2d (patch) | |
tree | 8a3d31f8efcb67c2e815938be17abd03952a7149 /lib/Analysis | |
parent | 39355f9fea790c5a1b12ef0fdcfeac3f533232ea (diff) | |
download | external_llvm-fe9388ccb4d2449e8e6a62053479a0ba74ae0b2d.zip external_llvm-fe9388ccb4d2449e8e6a62053479a0ba74ae0b2d.tar.gz external_llvm-fe9388ccb4d2449e8e6a62053479a0ba74ae0b2d.tar.bz2 |
Finish making AliasAnalysis aware of the fact that most atomic intrinsics only dereference their arguments, and enhance
BasicAA to make use of this fact when computing ModRef info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/AliasAnalysis.cpp | 21 | ||||
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 16 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 2571492..3e46fcc 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -150,6 +150,27 @@ AliasAnalysis::getModRefBehavior(CallSite CS, AliasAnalysis::ModRefBehavior AliasAnalysis::getModRefBehavior(Function *F, std::vector<PointerAccessInfo> *Info) { + if (F->isIntrinsic()) { + switch (F->getIntrinsicID()) { + case Intrinsic::atomic_cmp_swap: + case Intrinsic::atomic_load_add: + case Intrinsic::atomic_load_and: + case Intrinsic::atomic_load_max: + case Intrinsic::atomic_load_min: + case Intrinsic::atomic_load_nand: + case Intrinsic::atomic_load_or: + case Intrinsic::atomic_load_sub: + case Intrinsic::atomic_load_umax: + case Intrinsic::atomic_load_umin: + case Intrinsic::atomic_load_xor: + case Intrinsic::atomic_swap: + // CAS and related intrinsics only access their arguments. + return AliasAnalysis::AccessesArguments; + default: + break; + } + } + if (F->doesNotAccessMemory()) // Can't do better than this. return DoesNotAccessMemory; diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index ccbe338..317e9d9 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -256,6 +256,22 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) { // AliasAnalysis::ModRefResult BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { + // If the function only accesses its arguments, it suffices to check that + // P does not alias any of those arguments. + if (AliasAnalysis::getModRefBehavior(CS, 0) == + AliasAnalysis::AccessesArguments) { + bool doesAlias = false; + for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); + AI != AE; ++AI) + if (alias(*AI, ~0U, P, Size) != NoAlias) { + doesAlias = true; + break; + } + + if (!doesAlias) + return NoModRef; + } + if (!isa<Constant>(P)) { const Value *Object = P->getUnderlyingObject(); |