diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-06-13 07:52:46 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-06-13 07:52:46 +0000 |
commit | f8e046b148cd6cea740886f9cdc29268a0b8eb74 (patch) | |
tree | a6569d00e668c2f32b6377b0954d2bc0ee68e9a6 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 254a5c07e7c962677f834d0ec4f6e1700d96e018 (diff) | |
download | llvm-f8e046b148cd6cea740886f9cdc29268a0b8eb74.zip llvm-f8e046b148cd6cea740886f9cdc29268a0b8eb74.tar.gz llvm-f8e046b148cd6cea740886f9cdc29268a0b8eb74.tar.bz2 |
It's possible that an all-zero GEP may be used as the argument to lifetime
intrinsics. In fact, we'll optimize a bitcast to that when possible. Detect it
when looking for the lifetime intrinsics.
No test case, noticed by inspection.
llvm-svn: 132906
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 8416170..3eeedab 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -734,11 +734,15 @@ static bool hasLifetimeMarkers(AllocaInst *AI) { if (AI->getType() == Int8PtrTy) return isUsedByLifetimeMarker(AI); - // Do a scan to find all the bitcasts to i8*. + // Do a scan to find all the bitcasts or GEPs to i8*. for (Value::use_iterator I = AI->use_begin(), E = AI->use_end(); I != E; ++I) { if (I->getType() != Int8PtrTy) continue; - if (!isa<BitCastInst>(*I)) continue; + if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(*I)) { + if (!GEPI->hasAllZeroIndices()) continue; + } else if (!isa<BitCastInst>(*I)) { + continue; + } if (isUsedByLifetimeMarker(*I)) return true; } |