diff options
author | Dan Gohman <gohman@apple.com> | 2009-08-18 14:58:19 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-08-18 14:58:19 +0000 |
commit | 6874a2ae033b7b5e1d0c10714e01d9c87480956a (patch) | |
tree | ce428698790658c836026f249449099e2447dac6 /lib/Transforms | |
parent | 848c29396271b8255653b6c6b61b5482bd72c293 (diff) | |
download | external_llvm-6874a2ae033b7b5e1d0c10714e01d9c87480956a.zip external_llvm-6874a2ae033b7b5e1d0c10714e01d9c87480956a.tar.gz external_llvm-6874a2ae033b7b5e1d0c10714e01d9c87480956a.tar.bz2 |
Fix a bug that caused globalopt to miscompile tramp3d: don't miss
unruly indices for arrays that are members of structs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79337 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 46ff307..6ec2012 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -426,13 +426,18 @@ static bool IsUserOfGlobalSafeForSRA(User *U, GlobalValue *GV) { // Scalar replacing *just* the outer index of the array is probably not // going to be a win anyway, so just give up. for (++GEPI; // Skip array index. - GEPI != E && (isa<ArrayType>(*GEPI) || isa<VectorType>(*GEPI)); + GEPI != E; ++GEPI) { uint64_t NumElements; if (const ArrayType *SubArrayTy = dyn_cast<ArrayType>(*GEPI)) NumElements = SubArrayTy->getNumElements(); - else - NumElements = cast<VectorType>(*GEPI)->getNumElements(); + else if (const VectorType *SubVectorTy = dyn_cast<VectorType>(*GEPI)) + NumElements = SubVectorTy->getNumElements(); + else { + assert(isa<StructType>(*GEPI) && + "Indexed GEP type is not array, vector, or struct!"); + continue; + } ConstantInt *IdxVal = dyn_cast<ConstantInt>(GEPI.getOperand()); if (!IdxVal || IdxVal->getZExtValue() >= NumElements) |