[opaque pointer type] More GEP IRBuilder API migrations...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2015-04-03 21:33:42 +00:00
parent 4615ac61c5
commit 4a86b381a3
12 changed files with 63 additions and 43 deletions

View File

@ -1609,12 +1609,11 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// %0 = GEP [10 x i8] addrspace(1)* X, ...
// addrspacecast i8 addrspace(1)* %0 to i8*
SmallVector<Value*, 8> Idx(GEP.idx_begin(), GEP.idx_end());
Value *NewGEP =
GEP.isInBounds()
? Builder->CreateInBoundsGEP(StrippedPtr, Idx,
GEP.getName())
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
StrippedPtr, Idx, GEP.getName());
Value *NewGEP = GEP.isInBounds()
? Builder->CreateInBoundsGEP(
nullptr, StrippedPtr, Idx, GEP.getName())
: Builder->CreateGEP(nullptr, StrippedPtr, Idx,
GEP.getName());
return new AddrSpaceCastInst(NewGEP, GEP.getType());
}
}
@ -1632,9 +1631,9 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
Value *Idx[2] = { Constant::getNullValue(IdxType), GEP.getOperand(1) };
Value *NewGEP =
GEP.isInBounds()
? Builder->CreateInBoundsGEP(StrippedPtr, Idx, GEP.getName())
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
StrippedPtr, Idx, GEP.getName());
? Builder->CreateInBoundsGEP(nullptr, StrippedPtr, Idx,
GEP.getName())
: Builder->CreateGEP(nullptr, StrippedPtr, Idx, GEP.getName());
// V and GEP are both pointer types --> BitCast
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
@ -1667,10 +1666,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// GEP may not be "inbounds".
Value *NewGEP =
GEP.isInBounds() && NSW
? Builder->CreateInBoundsGEP(StrippedPtr, NewIdx,
? Builder->CreateInBoundsGEP(nullptr, StrippedPtr, NewIdx,
GEP.getName())
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
StrippedPtr, NewIdx, GEP.getName());
: Builder->CreateGEP(nullptr, StrippedPtr, NewIdx,
GEP.getName());
// The NewGEP must be pointer typed, so must the old one -> BitCast
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
@ -1708,9 +1707,11 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
Constant::getNullValue(DL.getIntPtrType(GEP.getType())),
NewIdx};
Value *NewGEP = GEP.isInBounds() && NSW ?
Builder->CreateInBoundsGEP(StrippedPtr, Off, GEP.getName()) :
Builder->CreateGEP(SrcElTy, StrippedPtr, Off, GEP.getName());
Value *NewGEP = GEP.isInBounds() && NSW
? Builder->CreateInBoundsGEP(
SrcElTy, StrippedPtr, Off, GEP.getName())
: Builder->CreateGEP(SrcElTy, StrippedPtr, Off,
GEP.getName());
// The NewGEP must be pointer typed, so must the old one -> BitCast
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
GEP.getType());
@ -1772,9 +1773,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// GEP.
SmallVector<Value*, 8> NewIndices;
if (FindElementAtOffset(OpType, Offset.getSExtValue(), NewIndices)) {
Value *NGEP = GEP.isInBounds() ?
Builder->CreateInBoundsGEP(Operand, NewIndices) :
Builder->CreateGEP(OpType->getElementType(), Operand, NewIndices);
Value *NGEP =
GEP.isInBounds()
? Builder->CreateInBoundsGEP(nullptr, Operand, NewIndices)
: Builder->CreateGEP(nullptr, Operand, NewIndices);
if (NGEP->getType() == GEP.getType())
return ReplaceInstUsesWith(GEP, NGEP);
@ -2266,7 +2268,8 @@ Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
// We need to insert these at the location of the old load, not at that of
// the extractvalue.
Builder->SetInsertPoint(L->getParent(), L);
Value *GEP = Builder->CreateInBoundsGEP(L->getPointerOperand(), Indices);
Value *GEP = Builder->CreateInBoundsGEP(L->getType(),
L->getPointerOperand(), Indices);
// Returning the load directly will cause the main loop to insert it in
// the wrong spot, so use ReplaceInstUsesWith().
return ReplaceInstUsesWith(EV, Builder->CreateLoad(GEP));