diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-12-02 06:44:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-12-02 06:44:58 +0000 |
| commit | c468025ac992eff8cd7158708b6cefd31c306c34 (patch) | |
| tree | 4f34df9e2cf1b1c40a843e8c092f6e96bbd05352 | |
| parent | 2764b4dc55d77e2b079449bfdaf45dd2e2a2c4b3 (diff) | |
| download | bcm5719-llvm-c468025ac992eff8cd7158708b6cefd31c306c34.tar.gz bcm5719-llvm-c468025ac992eff8cd7158708b6cefd31c306c34.zip | |
factor some code better.
llvm-svn: 90299
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 6f1c32c004e..1b42c6b9592 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/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. |

