diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-05-06 23:49:14 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-05-06 23:49:14 +0000 |
commit | e66a45fdb4ceb0ffab3ae1d5452583f9b064aecc (patch) | |
tree | b5b39342aae4ce8a29e825922b90b7c9e058b31c /llvm/lib/IR/Constants.cpp | |
parent | 74b63ebd53c292d95388b2159b26fb510af3ae3f (diff) | |
download | llvm-e66a45fdb4ceb0ffab3ae1d5452583f9b064aecc.zip llvm-e66a45fdb4ceb0ffab3ae1d5452583f9b064aecc.tar.gz llvm-e66a45fdb4ceb0ffab3ae1d5452583f9b064aecc.tar.bz2 |
[opaque pointer type] Pass explicit pointer type through GEP constant folding
llvm-svn: 236670
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 20a5206..b598c28 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!"); |