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 | 2b2bd289730f8f0ceef7638c462686607aae989f (patch) | |
| tree | dffe2a9d1efcd13fa8ec51d5fd37d61bffb580b0 /llvm/lib/Transforms/Scalar/GVN.cpp | |
| parent | 175308c43e49bfeb56e8aefb52eedc2139665cf7 (diff) | |
| download | bcm5719-llvm-2b2bd289730f8f0ceef7638c462686607aae989f.tar.gz bcm5719-llvm-2b2bd289730f8f0ceef7638c462686607aae989f.zip | |
Treat lifetime begin/end markers as allocations/frees respectively for the
purposes for GVN/DSE.
llvm-svn: 85383
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVN.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 32d027aa36d..dd8859b5e84 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1248,6 +1248,15 @@ bool GVN::processNonLocalLoad(LoadInst *LI, 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 @@ -1591,6 +1600,18 @@ bool GVN::processLoad(LoadInst *L, SmallVectorImpl<Instruction*> &toErase) { NumGVNLoad++; return true; } + + // If this load occurs either right after a lifetime begin or a lifetime end, + // then the loaded value is undefined. + if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(DepInst)) { + if (II->getIntrinsicID() == Intrinsic::lifetime_start || + II->getIntrinsicID() == Intrinsic::lifetime_end) { + L->replaceAllUsesWith(UndefValue::get(L->getType())); + toErase.push_back(L); + NumGVNLoad++; + return true; + } + } return false; } |

