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 | 9a488a831784c71acf552d9630a6c25ce8d3c3e9 (patch) | |
tree | 8939d6c284832cee3620ab37caa68632f5d885f9 /lib/Transforms | |
parent | 5e5ed4457749995b46d46e9769e657fcc0818e2c (diff) | |
download | external_llvm-9a488a831784c71acf552d9630a6c25ce8d3c3e9.zip external_llvm-9a488a831784c71acf552d9630a6c25ce8d3c3e9.tar.gz external_llvm-9a488a831784c71acf552d9630a6c25ce8d3c3e9.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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 8416170..3eeedab 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/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; } |