aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-02 06:44:58 +0000
committerChris Lattner <sabre@nondot.org>2009-12-02 06:44:58 +0000
commit720e790480fed373752b84c178c1a9798d4415b8 (patch)
tree000807eb6c19c26fc515880c69baedfff9795772
parent65a9ab4f8f75216f92a06ac2fe84d16ed7f0ccae (diff)
factor some code better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90299 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/GVN.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 6f1c32c004..1b42c6b959 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1187,6 +1187,13 @@ static Value *ConstructSSAForLoadSet(LoadInst *LI,
return V;
}
+static bool isLifetimeStartOrEnd(Instruction *Inst) {
+ if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(Inst))
+ return II->getIntrinsicID() == Intrinsic::lifetime_start ||
+ II->getIntrinsicID() == Intrinsic::lifetime_end;
+ return false;
+}
+
/// processNonLocalLoad - Attempt to eliminate a load whose dependencies are
/// non-local by performing PHI construction.
bool GVN::processNonLocalLoad(LoadInst *LI,
@@ -1254,21 +1261,14 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
Instruction *DepInst = DepInfo.getInst();
// Loading the allocation -> undef.
- if (isa<AllocaInst>(DepInst) || isMalloc(DepInst)) {
+ if (isa<AllocaInst>(DepInst) || isMalloc(DepInst) ||
+ // Loading immediately after lifetime begin or end -> undef.
+ isLifetimeStartOrEnd(DepInst)) {
ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB,
UndefValue::get(LI->getType())));
continue;
}
- // Loading immediately after lifetime begin or end -> undef.
- if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(DepInst)) {
- if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
- II->getIntrinsicID() == Intrinsic::lifetime_end) {
- ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB,
- UndefValue::get(LI->getType())));
- }
- }
-
if (StoreInst *S = dyn_cast<StoreInst>(DepInst)) {
// Reject loads and stores that are to the same address but are of
// different types if we have to.