diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-10 02:35:41 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-10 02:35:41 +0000 |
commit | d47f42435ae9fe8a9f4941fd79ac315d4ea46bcf (patch) | |
tree | 847f4adb5760fce1408d77a439da67c4f26d0718 /llvm/lib | |
parent | a00b97f7806aa0fe681ff6b07299e3101f13efbc (diff) | |
download | bcm5719-llvm-d47f42435ae9fe8a9f4941fd79ac315d4ea46bcf.tar.gz bcm5719-llvm-d47f42435ae9fe8a9f4941fd79ac315d4ea46bcf.zip |
[BasicAA] Guard intrinsics don't write to memory
Summary:
The idea is very close to what we do for assume intrinsics: we mark the
guard intrinsics as writing to arbitrary memory to maintain control
dependence, but under the covers we teach AA that they do not mod any
particular memory location.
Reviewers: chandlerc, hfinkel, gbiv, reames
Subscribers: george.burgess.iv, mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D19575
llvm-svn: 269007
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 14d92d633b9..0b5c85813b4 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -649,9 +649,9 @@ ModRefInfo BasicAAResult::getArgModRefInfo(ImmutableCallSite CS, return AAResultBase::getArgModRefInfo(CS, ArgIdx); } -static bool isAssumeIntrinsic(ImmutableCallSite CS) { +static bool isIntrinsicCall(ImmutableCallSite CS, Intrinsic::ID IID) { const IntrinsicInst *II = dyn_cast<IntrinsicInst>(CS.getInstruction()); - return II && II->getIntrinsicID() == Intrinsic::assume; + return II && II->getIntrinsicID() == IID; } #ifndef NDEBUG @@ -769,9 +769,19 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS, // While the assume intrinsic is marked as arbitrarily writing so that // proper control dependencies will be maintained, it never aliases any // particular memory location. - if (isAssumeIntrinsic(CS)) + if (isIntrinsicCall(CS, Intrinsic::assume)) return MRI_NoModRef; + // Like assumes, guard intrinsics are also marked as arbitrarily writing so + // that proper control dependencies are maintained but they never mods any + // particular memory location. + // + // *Unlike* assumes, guard intrinsics are modeled as reading memory since the + // heap state at the point the guard is issued needs to be consistent in case + // the guard invokes the "deopt" continuation. + if (isIntrinsicCall(CS, Intrinsic::experimental_guard)) + return MRI_Ref; + // The AAResultBase base class has some smarts, lets use them. return AAResultBase::getModRefInfo(CS, Loc); } @@ -781,9 +791,27 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS1, // While the assume intrinsic is marked as arbitrarily writing so that // proper control dependencies will be maintained, it never aliases any // particular memory location. - if (isAssumeIntrinsic(CS1) || isAssumeIntrinsic(CS2)) + if (isIntrinsicCall(CS1, Intrinsic::assume) || + isIntrinsicCall(CS2, Intrinsic::assume)) return MRI_NoModRef; + // Like assumes, guard intrinsics are also marked as arbitrarily writing so + // that proper control dependencies are maintained but they never mod any + // particular memory location. + // + // *Unlike* assumes, guard intrinsics are modeled as reading memory since the + // heap state at the point the guard is issued needs to be consistent in case + // the guard invokes the "deopt" continuation. + + // NB! This function is *not* commutative, so we specical case two + // possibilities for guard intrinsics. + + if (isIntrinsicCall(CS1, Intrinsic::experimental_guard)) + return getModRefBehavior(CS2) & MRI_Mod ? MRI_Ref : MRI_NoModRef; + + if (isIntrinsicCall(CS2, Intrinsic::experimental_guard)) + return getModRefBehavior(CS1) & MRI_Mod ? MRI_Mod : MRI_NoModRef; + // The AAResultBase base class has some smarts, lets use them. return AAResultBase::getModRefInfo(CS1, CS2); } |