diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-05-07 17:28:58 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-05-07 17:28:58 +0000 |
commit | d9d900c05b9a6011ade07264b148df4b032b9019 (patch) | |
tree | 95140abe69f78af1fa2197cbbc77ba96e05b18cc /llvm/lib/Transforms/IPO/GlobalOpt.cpp | |
parent | d3c127e232164e1f15eb901d047dbc409ac6198d (diff) | |
download | bcm5719-llvm-d9d900c05b9a6011ade07264b148df4b032b9019.tar.gz bcm5719-llvm-d9d900c05b9a6011ade07264b148df4b032b9019.zip |
Recommit r236670: [opaque pointer type] Pass explicit pointer type through GEP constant folding""
Clang regressions were caused by more stringent assertion checking
introduced by this change. Small fix needed to clang has been committed
in r236751.
llvm-svn: 236752
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index b8c4f5da39e..cc4a79fa67d 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -564,7 +564,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) { if (Val >= NewGlobals.size()) Val = 0; // Out of bound array access. Value *NewPtr = NewGlobals[Val]; - Type *NewTy = NewGlobals[Val]->getType(); + Type *NewTy = NewGlobals[Val]->getValueType(); // Form a shorter GEP if needed. if (GEP->getNumOperands() > 3) { @@ -575,7 +575,6 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) { Idxs.push_back(CE->getOperand(i)); NewPtr = ConstantExpr::getGetElementPtr(NewTy, cast<Constant>(NewPtr), Idxs); - NewTy = GetElementPtrInst::getIndexedType(NewTy, Idxs); } else { GetElementPtrInst *GEPI = cast<GetElementPtrInst>(GEP); SmallVector<Value*, 8> Idxs; @@ -583,8 +582,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) { for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i) Idxs.push_back(GEPI->getOperand(i)); NewPtr = GetElementPtrInst::Create( - NewPtr->getType()->getPointerElementType(), NewPtr, Idxs, - GEPI->getName() + "." + Twine(Val), GEPI); + NewTy, NewPtr, Idxs, GEPI->getName() + "." + Twine(Val), GEPI); } } GEP->replaceAllUsesWith(NewPtr); |