[llvm] Drop some more typed pointer bitcasts etc.
This commit is contained in:
@@ -7841,9 +7841,7 @@ static bool splitMergedValStore(StoreInst &SI, const DataLayout &DL,
|
||||
bool IsLE = SI.getModule()->getDataLayout().isLittleEndian();
|
||||
auto CreateSplitStore = [&](Value *V, bool Upper) {
|
||||
V = Builder.CreateZExtOrBitCast(V, SplitStoreType);
|
||||
Value *Addr = Builder.CreateBitCast(
|
||||
SI.getOperand(1),
|
||||
SplitStoreType->getPointerTo(SI.getPointerAddressSpace()));
|
||||
Value *Addr = SI.getPointerOperand();
|
||||
Align Alignment = SI.getAlign();
|
||||
const bool IsOffsetStore = (IsLE && Upper) || (!IsLE && !Upper);
|
||||
if (IsOffsetStore) {
|
||||
|
||||
@@ -689,7 +689,7 @@ llvm::createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
|
||||
LLT OpLLT = MRI.getType(Reg);
|
||||
Type *OpTy = nullptr;
|
||||
if (OpLLT.isPointer())
|
||||
OpTy = Type::getInt8PtrTy(Ctx, OpLLT.getAddressSpace());
|
||||
OpTy = PointerType::get(Ctx, OpLLT.getAddressSpace());
|
||||
else
|
||||
OpTy = IntegerType::get(Ctx, OpLLT.getSizeInBits());
|
||||
Args.push_back({Reg, OpTy, 0});
|
||||
|
||||
@@ -934,9 +934,8 @@ void LoadStoreOpt::initializeStoreMergeTargetInfo(unsigned AddrSpace) {
|
||||
BitVector LegalSizes(MaxStoreSizeToForm * 2);
|
||||
const auto &LI = *MF->getSubtarget().getLegalizerInfo();
|
||||
const auto &DL = MF->getFunction().getParent()->getDataLayout();
|
||||
Type *IntPtrIRTy =
|
||||
DL.getIntPtrType(MF->getFunction().getContext(), AddrSpace);
|
||||
LLT PtrTy = getLLTForType(*IntPtrIRTy->getPointerTo(AddrSpace), DL);
|
||||
Type *IRPtrTy = PointerType::get(MF->getFunction().getContext(), AddrSpace);
|
||||
LLT PtrTy = getLLTForType(*IRPtrTy, DL);
|
||||
// We assume that we're not going to be generating any stores wider than
|
||||
// MaxStoreSizeToForm bits for now.
|
||||
for (unsigned Size = 2; Size <= MaxStoreSizeToForm; Size *= 2) {
|
||||
|
||||
@@ -120,7 +120,7 @@ void attachDebugInfo(GlobalVariable &GV, DISubprogram &SP) {
|
||||
|
||||
FunctionType *getCheckFunctionType(LLVMContext &Ctx) {
|
||||
Type *VoidTy = Type::getVoidTy(Ctx);
|
||||
PointerType *VoidPtrTy = Type::getInt8PtrTy(Ctx);
|
||||
PointerType *VoidPtrTy = PointerType::getUnqual(Ctx);
|
||||
return FunctionType::get(VoidTy, VoidPtrTy, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1770,7 +1770,7 @@ BlockAddress *BlockAddress::get(Function *F, BasicBlock *BB) {
|
||||
}
|
||||
|
||||
BlockAddress::BlockAddress(Function *F, BasicBlock *BB)
|
||||
: Constant(Type::getInt8PtrTy(F->getContext(), F->getAddressSpace()),
|
||||
: Constant(PointerType::get(F->getContext(), F->getAddressSpace()),
|
||||
Value::BlockAddressVal, &Op<0>(), 2) {
|
||||
setOperand(0, F);
|
||||
setOperand(1, BB);
|
||||
|
||||
@@ -2054,7 +2054,7 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
|
||||
// includes the load that feeds the stores. Check for an alias by generating
|
||||
// the base address and checking everything.
|
||||
Value *StoreBasePtr = Expander.expandCodeFor(StoreEv->getStart(),
|
||||
Builder.getInt8PtrTy(SI->getPointerAddressSpace()), ExpPt);
|
||||
Builder.getPtrTy(SI->getPointerAddressSpace()), ExpPt);
|
||||
Value *LoadBasePtr = nullptr;
|
||||
|
||||
bool Overlap = false;
|
||||
@@ -2125,7 +2125,7 @@ CleanupAndExit:
|
||||
// For a memcpy, we have to make sure that the input array is not being
|
||||
// mutated by the loop.
|
||||
LoadBasePtr = Expander.expandCodeFor(LoadEv->getStart(),
|
||||
Builder.getInt8PtrTy(LI->getPointerAddressSpace()), ExpPt);
|
||||
Builder.getPtrTy(LI->getPointerAddressSpace()), ExpPt);
|
||||
|
||||
SmallPtrSet<Instruction*, 2> Ignore2;
|
||||
Ignore2.insert(SI);
|
||||
|
||||
@@ -761,12 +761,8 @@ void ConstantHoistingPass::emitBaseConstants(Instruction *Base,
|
||||
if (Adj->Offset) {
|
||||
if (Adj->Ty) {
|
||||
// Constant being rebased is a ConstantExpr.
|
||||
PointerType *Int8PtrTy = Type::getInt8PtrTy(
|
||||
*Ctx, cast<PointerType>(Adj->Ty)->getAddressSpace());
|
||||
Base = new BitCastInst(Base, Int8PtrTy, "base_bitcast", Adj->MatInsertPt);
|
||||
Mat = GetElementPtrInst::Create(Type::getInt8Ty(*Ctx), Base, Adj->Offset,
|
||||
"mat_gep", Adj->MatInsertPt);
|
||||
Mat = new BitCastInst(Mat, Adj->Ty, "mat_bitcast", Adj->MatInsertPt);
|
||||
} else
|
||||
// Constant being rebased is a ConstantInt.
|
||||
Mat = BinaryOperator::Create(Instruction::Add, Base, Adj->Offset,
|
||||
|
||||
@@ -1640,7 +1640,7 @@ static PointerBounds expandBounds(const RuntimeCheckingPtrGroup *CG,
|
||||
Loop *TheLoop, Instruction *Loc,
|
||||
SCEVExpander &Exp) {
|
||||
LLVMContext &Ctx = Loc->getContext();
|
||||
Type *PtrArithTy = Type::getInt8PtrTy(Ctx, CG->AddressSpace);
|
||||
Type *PtrArithTy = PointerType::get(Ctx, CG->AddressSpace);
|
||||
|
||||
Value *Start = nullptr, *End = nullptr;
|
||||
LLVM_DEBUG(dbgs() << "LAA: Adding RT check for range:\n");
|
||||
@@ -1693,21 +1693,13 @@ Value *llvm::addRuntimeChecks(
|
||||
const PointerBounds &A = Check.first, &B = Check.second;
|
||||
// Check if two pointers (A and B) conflict where conflict is computed as:
|
||||
// start(A) <= end(B) && start(B) <= end(A)
|
||||
unsigned AS0 = A.Start->getType()->getPointerAddressSpace();
|
||||
unsigned AS1 = B.Start->getType()->getPointerAddressSpace();
|
||||
|
||||
assert((AS0 == B.End->getType()->getPointerAddressSpace()) &&
|
||||
(AS1 == A.End->getType()->getPointerAddressSpace()) &&
|
||||
assert((A.Start->getType()->getPointerAddressSpace() ==
|
||||
B.End->getType()->getPointerAddressSpace()) &&
|
||||
(B.Start->getType()->getPointerAddressSpace() ==
|
||||
A.End->getType()->getPointerAddressSpace()) &&
|
||||
"Trying to bounds check pointers with different address spaces");
|
||||
|
||||
Type *PtrArithTy0 = Type::getInt8PtrTy(Ctx, AS0);
|
||||
Type *PtrArithTy1 = Type::getInt8PtrTy(Ctx, AS1);
|
||||
|
||||
Value *Start0 = ChkBuilder.CreateBitCast(A.Start, PtrArithTy0, "bc");
|
||||
Value *Start1 = ChkBuilder.CreateBitCast(B.Start, PtrArithTy1, "bc");
|
||||
Value *End0 = ChkBuilder.CreateBitCast(A.End, PtrArithTy1, "bc");
|
||||
Value *End1 = ChkBuilder.CreateBitCast(B.End, PtrArithTy0, "bc");
|
||||
|
||||
// [A|B].Start points to the first accessed byte under base [A|B].
|
||||
// [A|B].End points to the last accessed byte, plus one.
|
||||
// There is no conflict when the intervals are disjoint:
|
||||
@@ -1716,8 +1708,8 @@ Value *llvm::addRuntimeChecks(
|
||||
// bound0 = (B.Start < A.End)
|
||||
// bound1 = (A.Start < B.End)
|
||||
// IsConflict = bound0 & bound1
|
||||
Value *Cmp0 = ChkBuilder.CreateICmpULT(Start0, End1, "bound0");
|
||||
Value *Cmp1 = ChkBuilder.CreateICmpULT(Start1, End0, "bound1");
|
||||
Value *Cmp0 = ChkBuilder.CreateICmpULT(A.Start, B.End, "bound0");
|
||||
Value *Cmp1 = ChkBuilder.CreateICmpULT(B.Start, A.End, "bound1");
|
||||
Value *IsConflict = ChkBuilder.CreateAnd(Cmp0, Cmp1, "found.conflict");
|
||||
if (MemoryRuntimeCheck) {
|
||||
IsConflict =
|
||||
|
||||
@@ -170,11 +170,10 @@ Value *SCEVExpander::InsertNoopCastOfTo(Value *V, Type *Ty) {
|
||||
if (Op == Instruction::IntToPtr) {
|
||||
auto *PtrTy = cast<PointerType>(Ty);
|
||||
if (DL.isNonIntegralPointerType(PtrTy)) {
|
||||
auto *Int8PtrTy = Builder.getInt8PtrTy(PtrTy->getAddressSpace());
|
||||
assert(DL.getTypeAllocSize(Builder.getInt8Ty()) == 1 &&
|
||||
"alloc size of i8 must by 1 byte for the GEP to be correct");
|
||||
return Builder.CreateGEP(
|
||||
Builder.getInt8Ty(), Constant::getNullValue(Int8PtrTy), V, "scevgep");
|
||||
Builder.getInt8Ty(), Constant::getNullValue(PtrTy), V, "scevgep");
|
||||
}
|
||||
}
|
||||
// Short-circuit unnecessary bitcasts.
|
||||
@@ -2138,8 +2137,7 @@ Value *SCEVExpander::generateOverflowCheck(const SCEVAddRecExpr *AR,
|
||||
bool NeedNegCheck = !SE.isKnownPositive(Step);
|
||||
|
||||
if (PointerType *ARPtrTy = dyn_cast<PointerType>(ARTy)) {
|
||||
StartValue = InsertNoopCastOfTo(
|
||||
StartValue, Builder.getInt8PtrTy(ARPtrTy->getAddressSpace()));
|
||||
StartValue = InsertNoopCastOfTo(StartValue, ARPtrTy);
|
||||
Value *NegMulV = Builder.CreateNeg(MulV);
|
||||
if (NeedPosCheck)
|
||||
Add = Builder.CreateGEP(Builder.getInt8Ty(), StartValue, MulV);
|
||||
@@ -2245,7 +2243,7 @@ Value *SCEVExpander::fixupLCSSAFormFor(Value *V) {
|
||||
// instruction.
|
||||
Type *ToTy;
|
||||
if (DefI->getType()->isIntegerTy())
|
||||
ToTy = DefI->getType()->getPointerTo();
|
||||
ToTy = PointerType::get(DefI->getContext(), 0);
|
||||
else
|
||||
ToTy = Type::getInt32Ty(DefI->getContext());
|
||||
Instruction *User =
|
||||
|
||||
@@ -21,18 +21,12 @@ define dso_local void @zot() {
|
||||
; CHECK-NEXT: bb:
|
||||
; CHECK-NEXT: [[CONST:%.*]] = bitcast ptr getelementptr inbounds ([[TMP0:%.*]], ptr @global, i32 0, i32 4, i32 0, i32 0) to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[CONST]], align 4
|
||||
; CHECK-NEXT: [[BASE_BITCAST:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[BASE_BITCAST]], i32 4
|
||||
; CHECK-NEXT: [[MAT_BITCAST:%.*]] = bitcast ptr [[MAT_GEP]] to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST]], align 4
|
||||
; CHECK-NEXT: [[BASE_BITCAST1:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP2:%.*]] = getelementptr i8, ptr [[BASE_BITCAST1]], i32 160
|
||||
; CHECK-NEXT: [[MAT_BITCAST3:%.*]] = bitcast ptr [[MAT_GEP2]] to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST3]], align 4
|
||||
; CHECK-NEXT: [[BASE_BITCAST4:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP5:%.*]] = getelementptr i8, ptr [[BASE_BITCAST4]], i32 164
|
||||
; CHECK-NEXT: [[MAT_BITCAST6:%.*]] = bitcast ptr [[MAT_GEP5]] to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST6]], align 4
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[CONST]], i32 4
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_GEP]], align 4
|
||||
; CHECK-NEXT: [[MAT_GEP1:%.*]] = getelementptr i8, ptr [[CONST]], i32 160
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_GEP1]], align 4
|
||||
; CHECK-NEXT: [[MAT_GEP2:%.*]] = getelementptr i8, ptr [[CONST]], i32 164
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_GEP2]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
bb:
|
||||
|
||||
@@ -13,14 +13,10 @@ define void @test_inbounds() {
|
||||
; CHECK-NEXT: bb:
|
||||
; CHECK-NEXT: [[CONST:%.*]] = bitcast ptr getelementptr inbounds ([[TMP0:%.*]], ptr @global, i32 0, i32 1, i32 0) to ptr
|
||||
; CHECK-NEXT: store i16 undef, ptr [[CONST]], align 2
|
||||
; CHECK-NEXT: [[BASE_BITCAST:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[BASE_BITCAST]], i32 2
|
||||
; CHECK-NEXT: [[MAT_BITCAST:%.*]] = bitcast ptr [[MAT_GEP]] to ptr
|
||||
; CHECK-NEXT: store i16 undef, ptr [[MAT_BITCAST]], align 2
|
||||
; CHECK-NEXT: [[BASE_BITCAST1:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP2:%.*]] = getelementptr i8, ptr [[BASE_BITCAST1]], i32 20
|
||||
; CHECK-NEXT: [[MAT_BITCAST3:%.*]] = bitcast ptr [[MAT_GEP2]] to ptr
|
||||
; CHECK-NEXT: store i16 undef, ptr [[MAT_BITCAST3]], align 2
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[CONST]], i32 2
|
||||
; CHECK-NEXT: store i16 undef, ptr [[MAT_GEP]], align 2
|
||||
; CHECK-NEXT: [[MAT_GEP1:%.*]] = getelementptr i8, ptr [[CONST]], i32 20
|
||||
; CHECK-NEXT: store i16 undef, ptr [[MAT_GEP1]], align 2
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
bb:
|
||||
|
||||
@@ -23,15 +23,11 @@ define dso_local void @zot() {
|
||||
; CHECK-NEXT: [[CONST1:%.*]] = bitcast ptr getelementptr inbounds ([[TMP0:%.*]], ptr @global, i32 0, i32 4, i32 11, i32 0) to ptr
|
||||
; CHECK-NEXT: [[CONST:%.*]] = bitcast ptr getelementptr inbounds ([[TMP0]], ptr @global, i32 0, i32 4, i32 0, i32 0) to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[CONST]], align 4
|
||||
; CHECK-NEXT: [[BASE_BITCAST:%.*]] = bitcast ptr [[CONST]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[BASE_BITCAST]], i32 4
|
||||
; CHECK-NEXT: [[MAT_BITCAST:%.*]] = bitcast ptr [[MAT_GEP]] to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST]], align 4
|
||||
; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, ptr [[CONST]], i32 4
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_GEP]], align 4
|
||||
; CHECK-NEXT: store i32 undef, ptr [[CONST1]], align 4
|
||||
; CHECK-NEXT: [[BASE_BITCAST2:%.*]] = bitcast ptr [[CONST1]] to ptr
|
||||
; CHECK-NEXT: [[MAT_GEP3:%.*]] = getelementptr i8, ptr [[BASE_BITCAST2]], i32 4
|
||||
; CHECK-NEXT: [[MAT_BITCAST4:%.*]] = bitcast ptr [[MAT_GEP3]] to ptr
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_BITCAST4]], align 4
|
||||
; CHECK-NEXT: [[MAT_GEP2:%.*]] = getelementptr i8, ptr [[CONST1]], i32 4
|
||||
; CHECK-NEXT: store i32 undef, ptr [[MAT_GEP2]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
bb:
|
||||
|
||||
Reference in New Issue
Block a user