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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2015-05-07 17:28:58 +00:00
parent aa46024ea3
commit ad80c2d9ed
4 changed files with 36 additions and 16 deletions

View File

@ -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!");