mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-08 15:24:21 +00:00
[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:
@ -21,6 +21,7 @@
|
|||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
#include "llvm/IR/ConstantFolder.h"
|
#include "llvm/IR/ConstantFolder.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
|
#include "llvm/IR/GlobalVariable.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
#include "llvm/IR/LLVMContext.h"
|
#include "llvm/IR/LLVMContext.h"
|
||||||
#include "llvm/IR/Operator.h"
|
#include "llvm/IR/Operator.h"
|
||||||
@ -243,7 +244,7 @@ public:
|
|||||||
/// filled in with the null terminated string value specified. The new global
|
/// filled in with the null terminated string value specified. The new global
|
||||||
/// variable will be marked mergable with any others of the same contents. If
|
/// variable will be marked mergable with any others of the same contents. If
|
||||||
/// Name is specified, it is the name of the global variable created.
|
/// Name is specified, it is the name of the global variable created.
|
||||||
Value *CreateGlobalString(StringRef Str, const Twine &Name = "");
|
GlobalVariable *CreateGlobalString(StringRef Str, const Twine &Name = "");
|
||||||
|
|
||||||
/// \brief Get a constant value representing either true or false.
|
/// \brief Get a constant value representing either true or false.
|
||||||
ConstantInt *getInt1(bool V) {
|
ConstantInt *getInt1(bool V) {
|
||||||
@ -1034,6 +1035,10 @@ public:
|
|||||||
}
|
}
|
||||||
Value *CreateInBoundsGEP(Value *Ptr, ArrayRef<Value *> IdxList,
|
Value *CreateInBoundsGEP(Value *Ptr, ArrayRef<Value *> IdxList,
|
||||||
const Twine &Name = "") {
|
const Twine &Name = "") {
|
||||||
|
return CreateInBoundsGEP(nullptr, Ptr, IdxList, Name);
|
||||||
|
}
|
||||||
|
Value *CreateInBoundsGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
|
||||||
|
const Twine &Name = "") {
|
||||||
if (Constant *PC = dyn_cast<Constant>(Ptr)) {
|
if (Constant *PC = dyn_cast<Constant>(Ptr)) {
|
||||||
// Every index must be constant.
|
// Every index must be constant.
|
||||||
size_t i, e;
|
size_t i, e;
|
||||||
@ -1041,10 +1046,10 @@ public:
|
|||||||
if (!isa<Constant>(IdxList[i]))
|
if (!isa<Constant>(IdxList[i]))
|
||||||
break;
|
break;
|
||||||
if (i == e)
|
if (i == e)
|
||||||
return Insert(Folder.CreateInBoundsGetElementPtr(nullptr, PC, IdxList),
|
return Insert(Folder.CreateInBoundsGetElementPtr(Ty, PC, IdxList),
|
||||||
Name);
|
Name);
|
||||||
}
|
}
|
||||||
return Insert(GetElementPtrInst::CreateInBounds(nullptr, Ptr, IdxList), Name);
|
return Insert(GetElementPtrInst::CreateInBounds(Ty, Ptr, IdxList), Name);
|
||||||
}
|
}
|
||||||
Value *CreateGEP(Value *Ptr, Value *Idx, const Twine &Name = "") {
|
Value *CreateGEP(Value *Ptr, Value *Idx, const Twine &Name = "") {
|
||||||
return CreateGEP(nullptr, Ptr, Idx, Name);
|
return CreateGEP(nullptr, Ptr, Idx, Name);
|
||||||
@ -1153,10 +1158,10 @@ public:
|
|||||||
/// \brief Same as CreateGlobalString, but return a pointer with "i8*" type
|
/// \brief Same as CreateGlobalString, but return a pointer with "i8*" type
|
||||||
/// instead of a pointer to array of i8.
|
/// instead of a pointer to array of i8.
|
||||||
Value *CreateGlobalStringPtr(StringRef Str, const Twine &Name = "") {
|
Value *CreateGlobalStringPtr(StringRef Str, const Twine &Name = "") {
|
||||||
Value *gv = CreateGlobalString(Str, Name);
|
GlobalVariable *gv = CreateGlobalString(Str, Name);
|
||||||
Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
|
Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
|
||||||
Value *Args[] = { zero, zero };
|
Value *Args[] = { zero, zero };
|
||||||
return CreateInBoundsGEP(gv, Args, Name);
|
return CreateInBoundsGEP(gv->getValueType(), gv, Args, Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@ -1082,7 +1082,8 @@ static void ScalarizeMaskedLoad(CallInst *CI) {
|
|||||||
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.load");
|
CondBlock = IfBlock->splitBasicBlock(InsertPt, "cond.load");
|
||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
|
|
||||||
Value* Gep = Builder.CreateInBoundsGEP(FirstEltPtr, Builder.getInt32(Idx));
|
Value *Gep =
|
||||||
|
Builder.CreateInBoundsGEP(EltTy, FirstEltPtr, Builder.getInt32(Idx));
|
||||||
LoadInst* Load = Builder.CreateLoad(Gep, false);
|
LoadInst* Load = Builder.CreateLoad(Gep, false);
|
||||||
VResult = Builder.CreateInsertElement(VResult, Load, Builder.getInt32(Idx));
|
VResult = Builder.CreateInsertElement(VResult, Load, Builder.getInt32(Idx));
|
||||||
|
|
||||||
@ -1176,7 +1177,8 @@ static void ScalarizeMaskedStore(CallInst *CI) {
|
|||||||
Builder.SetInsertPoint(InsertPt);
|
Builder.SetInsertPoint(InsertPt);
|
||||||
|
|
||||||
Value *OneElt = Builder.CreateExtractElement(Src, Builder.getInt32(Idx));
|
Value *OneElt = Builder.CreateExtractElement(Src, Builder.getInt32(Idx));
|
||||||
Value* Gep = Builder.CreateInBoundsGEP(FirstEltPtr, Builder.getInt32(Idx));
|
Value *Gep =
|
||||||
|
Builder.CreateInBoundsGEP(EltTy, FirstEltPtr, Builder.getInt32(Idx));
|
||||||
Builder.CreateStore(OneElt, Gep);
|
Builder.CreateStore(OneElt, Gep);
|
||||||
|
|
||||||
// Create "else" block, fill it in the next iteration
|
// Create "else" block, fill it in the next iteration
|
||||||
|
@ -2512,7 +2512,8 @@ LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
|
|||||||
LLVMValueRef *Indices, unsigned NumIndices,
|
LLVMValueRef *Indices, unsigned NumIndices,
|
||||||
const char *Name) {
|
const char *Name) {
|
||||||
ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
|
ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
|
||||||
return wrap(unwrap(B)->CreateInBoundsGEP(unwrap(Pointer), IdxList, Name));
|
return wrap(
|
||||||
|
unwrap(B)->CreateInBoundsGEP(nullptr, unwrap(Pointer), IdxList, Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
|
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
|
||||||
|
@ -23,7 +23,8 @@ using namespace llvm;
|
|||||||
/// has array of i8 type filled in with the nul terminated string value
|
/// has array of i8 type filled in with the nul terminated string value
|
||||||
/// specified. If Name is specified, it is the name of the global variable
|
/// specified. If Name is specified, it is the name of the global variable
|
||||||
/// created.
|
/// created.
|
||||||
Value *IRBuilderBase::CreateGlobalString(StringRef Str, const Twine &Name) {
|
GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
|
||||||
|
const Twine &Name) {
|
||||||
Constant *StrConstant = ConstantDataArray::getString(Context, Str);
|
Constant *StrConstant = ConstantDataArray::getString(Context, Str);
|
||||||
Module &M = *BB->getParent()->getParent();
|
Module &M = *BB->getParent()->getParent();
|
||||||
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
|
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
|
||||||
|
@ -347,6 +347,7 @@ Value *GenericToNVVM::remapConstantExpr(Module *M, Function *F, ConstantExpr *C,
|
|||||||
NewOperands[0],
|
NewOperands[0],
|
||||||
makeArrayRef(&NewOperands[1], NumOperands - 1))
|
makeArrayRef(&NewOperands[1], NumOperands - 1))
|
||||||
: Builder.CreateInBoundsGEP(
|
: Builder.CreateInBoundsGEP(
|
||||||
|
cast<GEPOperator>(C)->getSourceElementType(),
|
||||||
NewOperands[0],
|
NewOperands[0],
|
||||||
makeArrayRef(&NewOperands[1], NumOperands - 1));
|
makeArrayRef(&NewOperands[1], NumOperands - 1));
|
||||||
case Instruction::Select:
|
case Instruction::Select:
|
||||||
|
@ -82,7 +82,8 @@ createReplacementInstr(ConstantExpr *CE, Instruction *Instr) {
|
|||||||
case Instruction::GetElementPtr: {
|
case Instruction::GetElementPtr: {
|
||||||
SmallVector<Value *,4> CEOpVec(CE->op_begin(), CE->op_end());
|
SmallVector<Value *,4> CEOpVec(CE->op_begin(), CE->op_end());
|
||||||
ArrayRef<Value *> CEOps(CEOpVec);
|
ArrayRef<Value *> CEOps(CEOpVec);
|
||||||
return dyn_cast<Instruction>(Builder.CreateInBoundsGEP(CEOps[0],
|
return dyn_cast<Instruction>(Builder.CreateInBoundsGEP(
|
||||||
|
cast<GEPOperator>(CE)->getSourceElementType(), CEOps[0],
|
||||||
CEOps.slice(1)));
|
CEOps.slice(1)));
|
||||||
}
|
}
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
@ -212,7 +213,8 @@ bool XCoreLowerThreadLocal::lowerGlobal(GlobalVariable *GV) {
|
|||||||
SmallVector<Value *, 2> Indices;
|
SmallVector<Value *, 2> Indices;
|
||||||
Indices.push_back(Constant::getNullValue(Type::getInt64Ty(Ctx)));
|
Indices.push_back(Constant::getNullValue(Type::getInt64Ty(Ctx)));
|
||||||
Indices.push_back(ThreadID);
|
Indices.push_back(ThreadID);
|
||||||
Value *Addr = Builder.CreateInBoundsGEP(NewGV, Indices);
|
Value *Addr =
|
||||||
|
Builder.CreateInBoundsGEP(NewGV->getValueType(), NewGV, Indices);
|
||||||
U->replaceUsesOfWith(GV, Addr);
|
U->replaceUsesOfWith(GV, Addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1609,12 +1609,11 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||||||
// %0 = GEP [10 x i8] addrspace(1)* X, ...
|
// %0 = GEP [10 x i8] addrspace(1)* X, ...
|
||||||
// addrspacecast i8 addrspace(1)* %0 to i8*
|
// addrspacecast i8 addrspace(1)* %0 to i8*
|
||||||
SmallVector<Value*, 8> Idx(GEP.idx_begin(), GEP.idx_end());
|
SmallVector<Value*, 8> Idx(GEP.idx_begin(), GEP.idx_end());
|
||||||
Value *NewGEP =
|
Value *NewGEP = GEP.isInBounds()
|
||||||
GEP.isInBounds()
|
? Builder->CreateInBoundsGEP(
|
||||||
? Builder->CreateInBoundsGEP(StrippedPtr, Idx,
|
nullptr, StrippedPtr, Idx, GEP.getName())
|
||||||
GEP.getName())
|
: Builder->CreateGEP(nullptr, StrippedPtr, Idx,
|
||||||
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
|
GEP.getName());
|
||||||
StrippedPtr, Idx, GEP.getName());
|
|
||||||
return new AddrSpaceCastInst(NewGEP, GEP.getType());
|
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 *Idx[2] = { Constant::getNullValue(IdxType), GEP.getOperand(1) };
|
||||||
Value *NewGEP =
|
Value *NewGEP =
|
||||||
GEP.isInBounds()
|
GEP.isInBounds()
|
||||||
? Builder->CreateInBoundsGEP(StrippedPtr, Idx, GEP.getName())
|
? Builder->CreateInBoundsGEP(nullptr, StrippedPtr, Idx,
|
||||||
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
|
GEP.getName())
|
||||||
StrippedPtr, Idx, GEP.getName());
|
: Builder->CreateGEP(nullptr, StrippedPtr, Idx, GEP.getName());
|
||||||
|
|
||||||
// V and GEP are both pointer types --> BitCast
|
// V and GEP are both pointer types --> BitCast
|
||||||
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
||||||
@ -1667,10 +1666,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||||||
// GEP may not be "inbounds".
|
// GEP may not be "inbounds".
|
||||||
Value *NewGEP =
|
Value *NewGEP =
|
||||||
GEP.isInBounds() && NSW
|
GEP.isInBounds() && NSW
|
||||||
? Builder->CreateInBoundsGEP(StrippedPtr, NewIdx,
|
? Builder->CreateInBoundsGEP(nullptr, StrippedPtr, NewIdx,
|
||||||
GEP.getName())
|
GEP.getName())
|
||||||
: Builder->CreateGEP(StrippedPtrTy->getElementType(),
|
: Builder->CreateGEP(nullptr, StrippedPtr, NewIdx,
|
||||||
StrippedPtr, NewIdx, GEP.getName());
|
GEP.getName());
|
||||||
|
|
||||||
// The NewGEP must be pointer typed, so must the old one -> BitCast
|
// The NewGEP must be pointer typed, so must the old one -> BitCast
|
||||||
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
||||||
@ -1708,9 +1707,11 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||||||
Constant::getNullValue(DL.getIntPtrType(GEP.getType())),
|
Constant::getNullValue(DL.getIntPtrType(GEP.getType())),
|
||||||
NewIdx};
|
NewIdx};
|
||||||
|
|
||||||
Value *NewGEP = GEP.isInBounds() && NSW ?
|
Value *NewGEP = GEP.isInBounds() && NSW
|
||||||
Builder->CreateInBoundsGEP(StrippedPtr, Off, GEP.getName()) :
|
? Builder->CreateInBoundsGEP(
|
||||||
Builder->CreateGEP(SrcElTy, StrippedPtr, Off, GEP.getName());
|
SrcElTy, StrippedPtr, Off, GEP.getName())
|
||||||
|
: Builder->CreateGEP(SrcElTy, StrippedPtr, Off,
|
||||||
|
GEP.getName());
|
||||||
// The NewGEP must be pointer typed, so must the old one -> BitCast
|
// The NewGEP must be pointer typed, so must the old one -> BitCast
|
||||||
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
return CastInst::CreatePointerBitCastOrAddrSpaceCast(NewGEP,
|
||||||
GEP.getType());
|
GEP.getType());
|
||||||
@ -1772,9 +1773,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||||||
// GEP.
|
// GEP.
|
||||||
SmallVector<Value*, 8> NewIndices;
|
SmallVector<Value*, 8> NewIndices;
|
||||||
if (FindElementAtOffset(OpType, Offset.getSExtValue(), NewIndices)) {
|
if (FindElementAtOffset(OpType, Offset.getSExtValue(), NewIndices)) {
|
||||||
Value *NGEP = GEP.isInBounds() ?
|
Value *NGEP =
|
||||||
Builder->CreateInBoundsGEP(Operand, NewIndices) :
|
GEP.isInBounds()
|
||||||
Builder->CreateGEP(OpType->getElementType(), Operand, NewIndices);
|
? Builder->CreateInBoundsGEP(nullptr, Operand, NewIndices)
|
||||||
|
: Builder->CreateGEP(nullptr, Operand, NewIndices);
|
||||||
|
|
||||||
if (NGEP->getType() == GEP.getType())
|
if (NGEP->getType() == GEP.getType())
|
||||||
return ReplaceInstUsesWith(GEP, NGEP);
|
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
|
// We need to insert these at the location of the old load, not at that of
|
||||||
// the extractvalue.
|
// the extractvalue.
|
||||||
Builder->SetInsertPoint(L->getParent(), L);
|
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
|
// Returning the load directly will cause the main loop to insert it in
|
||||||
// the wrong spot, so use ReplaceInstUsesWith().
|
// the wrong spot, so use ReplaceInstUsesWith().
|
||||||
return ReplaceInstUsesWith(EV, Builder->CreateLoad(GEP));
|
return ReplaceInstUsesWith(EV, Builder->CreateLoad(GEP));
|
||||||
|
@ -631,7 +631,8 @@ bool GCOVProfiler::emitProfileArcs() {
|
|||||||
SmallVector<Value *, 2> Idx;
|
SmallVector<Value *, 2> Idx;
|
||||||
Idx.push_back(Builder.getInt64(0));
|
Idx.push_back(Builder.getInt64(0));
|
||||||
Idx.push_back(Sel);
|
Idx.push_back(Sel);
|
||||||
Value *Counter = Builder.CreateInBoundsGEP(Counters, Idx);
|
Value *Counter = Builder.CreateInBoundsGEP(Counters->getValueType(),
|
||||||
|
Counters, Idx);
|
||||||
Value *Count = Builder.CreateLoad(Counter);
|
Value *Count = Builder.CreateLoad(Counter);
|
||||||
Count = Builder.CreateAdd(Count, Builder.getInt64(1));
|
Count = Builder.CreateAdd(Count, Builder.getInt64(1));
|
||||||
Builder.CreateStore(Count, Counter);
|
Builder.CreateStore(Count, Counter);
|
||||||
|
@ -1552,7 +1552,8 @@ static Value *buildGEP(IRBuilderTy &IRB, Value *BasePtr,
|
|||||||
if (Indices.size() == 1 && cast<ConstantInt>(Indices.back())->isZero())
|
if (Indices.size() == 1 && cast<ConstantInt>(Indices.back())->isZero())
|
||||||
return BasePtr;
|
return BasePtr;
|
||||||
|
|
||||||
return IRB.CreateInBoundsGEP(BasePtr, Indices, NamePrefix + "sroa_idx");
|
return IRB.CreateInBoundsGEP(nullptr, BasePtr, Indices,
|
||||||
|
NamePrefix + "sroa_idx");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Get a natural GEP off of the BasePtr walking through Ty toward
|
/// \brief Get a natural GEP off of the BasePtr walking through Ty toward
|
||||||
@ -1803,7 +1804,8 @@ static Value *getAdjustedPtr(IRBuilderTy &IRB, const DataLayout &DL, Value *Ptr,
|
|||||||
|
|
||||||
OffsetPtr = Int8PtrOffset == 0
|
OffsetPtr = Int8PtrOffset == 0
|
||||||
? Int8Ptr
|
? Int8Ptr
|
||||||
: IRB.CreateInBoundsGEP(Int8Ptr, IRB.getInt(Int8PtrOffset),
|
: IRB.CreateInBoundsGEP(IRB.getInt8Ty(), Int8Ptr,
|
||||||
|
IRB.getInt(Int8PtrOffset),
|
||||||
NamePrefix + "sroa_raw_idx");
|
NamePrefix + "sroa_raw_idx");
|
||||||
}
|
}
|
||||||
Ptr = OffsetPtr;
|
Ptr = OffsetPtr;
|
||||||
@ -3250,7 +3252,8 @@ private:
|
|||||||
void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
||||||
assert(Ty->isSingleValueType());
|
assert(Ty->isSingleValueType());
|
||||||
// Load the single value and insert it using the indices.
|
// Load the single value and insert it using the indices.
|
||||||
Value *GEP = IRB.CreateInBoundsGEP(Ptr, GEPIndices, Name + ".gep");
|
Value *GEP =
|
||||||
|
IRB.CreateInBoundsGEP(nullptr, Ptr, GEPIndices, Name + ".gep");
|
||||||
Value *Load = IRB.CreateLoad(GEP, Name + ".load");
|
Value *Load = IRB.CreateLoad(GEP, Name + ".load");
|
||||||
Agg = IRB.CreateInsertValue(Agg, Load, Indices, Name + ".insert");
|
Agg = IRB.CreateInsertValue(Agg, Load, Indices, Name + ".insert");
|
||||||
DEBUG(dbgs() << " to: " << *Load << "\n");
|
DEBUG(dbgs() << " to: " << *Load << "\n");
|
||||||
@ -3283,7 +3286,7 @@ private:
|
|||||||
// Extract the single value and store it using the indices.
|
// Extract the single value and store it using the indices.
|
||||||
Value *Store = IRB.CreateStore(
|
Value *Store = IRB.CreateStore(
|
||||||
IRB.CreateExtractValue(Agg, Indices, Name + ".extract"),
|
IRB.CreateExtractValue(Agg, Indices, Name + ".extract"),
|
||||||
IRB.CreateInBoundsGEP(Ptr, GEPIndices, Name + ".gep"));
|
IRB.CreateInBoundsGEP(nullptr, Ptr, GEPIndices, Name + ".gep"));
|
||||||
(void)Store;
|
(void)Store;
|
||||||
DEBUG(dbgs() << " to: " << *Store << "\n");
|
DEBUG(dbgs() << " to: " << *Store << "\n");
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,8 @@ void StraightLineStrengthReduce::rewriteCandidateWithBasis(
|
|||||||
Type *CharTy = Type::getInt8PtrTy(Basis.Ins->getContext(), AS);
|
Type *CharTy = Type::getInt8PtrTy(Basis.Ins->getContext(), AS);
|
||||||
Reduced = Builder.CreateBitCast(Basis.Ins, CharTy);
|
Reduced = Builder.CreateBitCast(Basis.Ins, CharTy);
|
||||||
if (InBounds)
|
if (InBounds)
|
||||||
Reduced = Builder.CreateInBoundsGEP(Reduced, Bump);
|
Reduced =
|
||||||
|
Builder.CreateInBoundsGEP(Builder.getInt8Ty(), Reduced, Bump);
|
||||||
else
|
else
|
||||||
Reduced = Builder.CreateGEP(Builder.getInt8Ty(), Reduced, Bump);
|
Reduced = Builder.CreateGEP(Builder.getInt8Ty(), Reduced, Bump);
|
||||||
Reduced = Builder.CreateBitCast(Reduced, C.Ins->getType());
|
Reduced = Builder.CreateBitCast(Reduced, C.Ins->getType());
|
||||||
@ -489,7 +490,7 @@ void StraightLineStrengthReduce::rewriteCandidateWithBasis(
|
|||||||
// Canonicalize bump to pointer size.
|
// Canonicalize bump to pointer size.
|
||||||
Bump = Builder.CreateSExtOrTrunc(Bump, IntPtrTy);
|
Bump = Builder.CreateSExtOrTrunc(Bump, IntPtrTy);
|
||||||
if (InBounds)
|
if (InBounds)
|
||||||
Reduced = Builder.CreateInBoundsGEP(Basis.Ins, Bump);
|
Reduced = Builder.CreateInBoundsGEP(nullptr, Basis.Ins, Bump);
|
||||||
else
|
else
|
||||||
Reduced = Builder.CreateGEP(nullptr, Basis.Ins, Bump);
|
Reduced = Builder.CreateGEP(nullptr, Basis.Ins, Bump);
|
||||||
}
|
}
|
||||||
|
@ -3884,8 +3884,8 @@ Value *SwitchLookupTable::BuildLookup(Value *Index, IRBuilder<> &Builder) {
|
|||||||
"switch.tableidx.zext");
|
"switch.tableidx.zext");
|
||||||
|
|
||||||
Value *GEPIndices[] = { Builder.getInt32(0), Index };
|
Value *GEPIndices[] = { Builder.getInt32(0), Index };
|
||||||
Value *GEP = Builder.CreateInBoundsGEP(Array, GEPIndices,
|
Value *GEP = Builder.CreateInBoundsGEP(Array->getValueType(), Array,
|
||||||
"switch.gep");
|
GEPIndices, "switch.gep");
|
||||||
return Builder.CreateLoad(GEP, "switch.load");
|
return Builder.CreateLoad(GEP, "switch.load");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ Value *LibCallSimplifier::optimizeStpCpy(CallInst *CI, IRBuilder<> &B) {
|
|||||||
Value *Dst = CI->getArgOperand(0), *Src = CI->getArgOperand(1);
|
Value *Dst = CI->getArgOperand(0), *Src = CI->getArgOperand(1);
|
||||||
if (Dst == Src) { // stpcpy(x,x) -> x+strlen(x)
|
if (Dst == Src) { // stpcpy(x,x) -> x+strlen(x)
|
||||||
Value *StrLen = EmitStrLen(Src, B, DL, TLI);
|
Value *StrLen = EmitStrLen(Src, B, DL, TLI);
|
||||||
return StrLen ? B.CreateInBoundsGEP(Dst, StrLen) : nullptr;
|
return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can get the length of the input string.
|
// See if we can get the length of the input string.
|
||||||
@ -2276,7 +2276,7 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
|
|||||||
// __stpcpy_chk(x,x,...) -> x+strlen(x)
|
// __stpcpy_chk(x,x,...) -> x+strlen(x)
|
||||||
if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
|
if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
|
||||||
Value *StrLen = EmitStrLen(Src, B, DL, TLI);
|
Value *StrLen = EmitStrLen(Src, B, DL, TLI);
|
||||||
return StrLen ? B.CreateInBoundsGEP(Dst, StrLen) : nullptr;
|
return StrLen ? B.CreateInBoundsGEP(B.getInt8Ty(), Dst, StrLen) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a) we don't have any length information, or b) we know this will
|
// If a) we don't have any length information, or b) we know this will
|
||||||
|
Reference in New Issue
Block a user