summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-05-07 17:28:58 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-05-07 17:28:58 +0000
commitd9d900c05b9a6011ade07264b148df4b032b9019 (patch)
tree95140abe69f78af1fa2197cbbc77ba96e05b18cc /llvm/lib/IR/Constants.cpp
parentd3c127e232164e1f15eb901d047dbc409ac6198d (diff)
downloadbcm5719-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/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 20a5206c230..b598c2807ce 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2015,14 +2015,16 @@ Constant *ConstantExpr::getSelect(Constant *C, Constant *V1, Constant *V2,
Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
ArrayRef<Value *> Idxs, bool InBounds,
Type *OnlyIfReducedTy) {
- if (Constant *FC = ConstantFoldGetElementPtr(C, InBounds, Idxs))
- return FC; // Fold a few common cases.
-
if (!Ty)
Ty = cast<PointerType>(C->getType()->getScalarType())->getElementType();
else
- assert(Ty ==
- cast<PointerType>(C->getType()->getScalarType())->getElementType());
+ assert(
+ Ty ==
+ cast<PointerType>(C->getType()->getScalarType())->getContainedType(0u));
+
+ if (Constant *FC = ConstantFoldGetElementPtr(Ty, C, InBounds, Idxs))
+ return FC; // Fold a few common cases.
+
// Get the result type of the getelementptr!
Type *DestTy = GetElementPtrInst::getIndexedType(Ty, Idxs);
assert(DestTy && "GEP indices invalid!");
OpenPOWER on IntegriCloud