summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2012-06-16 01:43:26 +0000
committerPete Cooper <peter_cooper@apple.com>2012-06-16 01:43:26 +0000
commit818e9f4a26a6c7aa0bdecb28b66ff30f44f9e4a6 (patch)
treeb47b250b08681becbca9e3d50b83881a50337b52 /llvm/lib/Transforms
parent2b50c40ebd9ee8f926232ab2a5b58152857fdcf9 (diff)
downloadbcm5719-llvm-818e9f4a26a6c7aa0bdecb28b66ff30f44f9e4a6.tar.gz
bcm5719-llvm-818e9f4a26a6c7aa0bdecb28b66ff30f44f9e4a6.zip
Fix crash from r158529 on Bullet.
Dynamic GEPs created by SROA needed to insert extra "i32 0" operands to index through structs and arrays to get to the vector being indexed. llvm-svn: 158590
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 9fc4164cc0e..bc428802e89 100644
--- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -2011,8 +2011,17 @@ void SROA::RewriteGEP(GetElementPtrInst *GEPI, AllocaInst *AI, uint64_t Offset,
uint64_t EltIdx = FindElementAndOffset(T, EltOffset, IdxTy);
NewArgs.push_back(ConstantInt::get(IdxTy, EltIdx));
}
- if (NonConstantIdx)
+ if (NonConstantIdx) {
+ Type* GepTy = T;
+ // This GEP has a dynamic index. We need to add "i32 0" to index through
+ // any structs or arrays in the original type until we get to the vector
+ // to index.
+ while (!isa<VectorType>(GepTy)) {
+ NewArgs.push_back(Constant::getNullValue(i32Ty));
+ GepTy = cast<CompositeType>(GepTy)->getTypeAtIndex(0U);
+ }
NewArgs.push_back(NonConstantIdx);
+ }
Instruction *Val = NewElts[Idx];
if (NewArgs.size() > 1) {
Val = GetElementPtrInst::CreateInBounds(Val, NewArgs, "", GEPI);
OpenPOWER on IntegriCloud