diff options
author | Owen Anderson <resistor@mac.com> | 2009-10-28 07:05:35 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-10-28 07:05:35 +0000 |
commit | b62f792e78df12a43029352eb4c7cde9d456c67e (patch) | |
tree | e2b4de6c1ad567c76b6038fe67a424b787a509f1 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 40cc524edee857eab238338200d2cc80f840f52f (diff) |
Treat lifetime begin/end markers as allocations/frees respectively for the
purposes for GVN/DSE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85383 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index be5f9c1ae0..0ec0e74233 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -185,10 +185,9 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, if (invariantTag == Inst) { invariantTag = 0; continue; - - // If we pass an invariant-end marker, then we've just entered an invariant - // region and can start ignoring dependencies. } else if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(Inst)) { + // If we pass an invariant-end marker, then we've just entered an + // invariant region and can start ignoring dependencies. if (II->getIntrinsicID() == Intrinsic::invariant_end) { uint64_t invariantSize = ~0ULL; if (ConstantInt* CI = dyn_cast<ConstantInt>(II->getOperand(2))) @@ -200,6 +199,19 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, invariantTag = II->getOperand(1); continue; } + + // If we reach a lifetime begin or end marker, then the query ends here + // because the value is undefined. + } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || + II->getIntrinsicID() == Intrinsic::lifetime_end) { + uint64_t invariantSize = ~0ULL; + if (ConstantInt* CI = dyn_cast<ConstantInt>(II->getOperand(1))) + invariantSize = CI->getZExtValue(); + + AliasAnalysis::AliasResult R = + AA->alias(II->getOperand(2), invariantSize, MemPtr, MemSize); + if (R == AliasAnalysis::MustAlias) + return MemDepResult::getDef(II); } } |