Skip to content

Commit e5026f0

Browse files
committed
[llvm] Remove uses of Type::getPointerTo() (NFC)
Partial progress towards removing in-tree uses of `getPointerTo()`, by employing the following options: * Drop the call entirely if the sole purpose of it is to support a no-op bitcast (remove the no-op bitcast as well). * Replace with `PointerType::get()`/`PointerType::getUnqual()` This is a NFC cleanup effort. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D155232
1 parent 193c67c commit e5026f0

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,7 @@ SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
22512251
// Also pass the return address of the remainder.
22522252
SDValue FIPtr = DAG.CreateStackTemporary(RetVT);
22532253
Entry.Node = FIPtr;
2254-
Entry.Ty = RetTy->getPointerTo();
2254+
Entry.Ty = PointerType::getUnqual(RetTy->getContext());
22552255
Entry.IsSExt = isSigned;
22562256
Entry.IsZExt = !isSigned;
22572257
Args.push_back(Entry);
@@ -2342,15 +2342,15 @@ SelectionDAGLegalize::ExpandSinCosLibCall(SDNode *Node,
23422342
// Pass the return address of sin.
23432343
SDValue SinPtr = DAG.CreateStackTemporary(RetVT);
23442344
Entry.Node = SinPtr;
2345-
Entry.Ty = RetTy->getPointerTo();
2345+
Entry.Ty = PointerType::getUnqual(RetTy->getContext());
23462346
Entry.IsSExt = false;
23472347
Entry.IsZExt = false;
23482348
Args.push_back(Entry);
23492349

23502350
// Also pass the return address of the cos.
23512351
SDValue CosPtr = DAG.CreateStackTemporary(RetVT);
23522352
Entry.Node = CosPtr;
2353-
Entry.Ty = RetTy->getPointerTo();
2353+
Entry.Ty = PointerType::getUnqual(RetTy->getContext());
23542354
Entry.IsSExt = false;
23552355
Entry.IsZExt = false;
23562356
Args.push_back(Entry);

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,9 +2853,7 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
28532853
auto *VecTy = cast<FixedVectorType>(CI->getType());
28542854
Type *EltTy = VecTy->getElementType();
28552855
unsigned EltNum = VecTy->getNumElements();
2856-
Value *Cast = Builder.CreateBitCast(CI->getArgOperand(0),
2857-
EltTy->getPointerTo());
2858-
Value *Load = Builder.CreateLoad(EltTy, Cast);
2856+
Value *Load = Builder.CreateLoad(EltTy, CI->getArgOperand(0));
28592857
Type *I32Ty = Type::getInt32Ty(C);
28602858
Rep = PoisonValue::get(VecTy);
28612859
for (unsigned I = 0; I < EltNum; ++I)

llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ auto AlignVectors::createAlignedPointer(IRBuilderBase &Builder, Value *Ptr,
706706
Value *AsInt = Builder.CreatePtrToInt(Ptr, HVC.getIntTy(), "pti");
707707
Value *Mask = HVC.getConstInt(-Alignment);
708708
Value *And = Builder.CreateAnd(remap(AsInt), Mask, "and");
709-
return Builder.CreateIntToPtr(And, ValTy->getPointerTo(), "itp");
709+
return Builder.CreateIntToPtr(
710+
And, PointerType::getUnqual(ValTy->getContext()), "itp");
710711
}
711712

712713
auto AlignVectors::createLoad(IRBuilderBase &Builder, Type *ValTy, Value *Ptr,

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5760,8 +5760,8 @@ InstructionCost X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy,
57605760
}
57615761

57625762
InstructionCost AddressUnpackCost = getScalarizationOverhead(
5763-
FixedVectorType::get(ScalarTy->getPointerTo(), VF), DemandedElts,
5764-
/*Insert=*/false, /*Extract=*/true, CostKind);
5763+
FixedVectorType::get(PointerType::getUnqual(ScalarTy->getContext()), VF),
5764+
DemandedElts, /*Insert=*/false, /*Extract=*/true, CostKind);
57655765

57665766
// The cost of the scalar loads/stores.
57675767
InstructionCost MemoryOpCost =

llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class PGOCounterPromoterHelper : public LoadAndStorePromoter {
190190
auto *OrigBiasInst = dyn_cast<BinaryOperator>(AddrInst->getOperand(0));
191191
assert(OrigBiasInst->getOpcode() == Instruction::BinaryOps::Add);
192192
Value *BiasInst = Builder.Insert(OrigBiasInst->clone());
193-
Addr = Builder.CreateIntToPtr(BiasInst, Ty->getPointerTo());
193+
Addr = Builder.CreateIntToPtr(BiasInst,
194+
PointerType::getUnqual(Ty->getContext()));
194195
}
195196
if (AtomicCounterUpdatePromoted)
196197
// automic update currently can only be promoted across the current

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,12 +3379,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
33793379
IRBuilder<> IRB(&I);
33803380
Value *Addr = I.getArgOperand(0);
33813381
Type *Ty = IRB.getInt32Ty();
3382-
Type *PtrTy = IRB.getPtrTy();
33833382
Value *ShadowPtr =
33843383
getShadowOriginPtr(Addr, IRB, Ty, Align(1), /*isStore*/ true).first;
33853384

3386-
IRB.CreateStore(getCleanShadow(Ty),
3387-
IRB.CreatePointerCast(ShadowPtr, PtrTy));
3385+
IRB.CreateStore(getCleanShadow(Ty), ShadowPtr);
33883386

33893387
if (ClCheckAccessAddress)
33903388
insertShadowCheck(Addr, &I);

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9476,7 +9476,8 @@ void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
94769476
const DataLayout &DL =
94779477
Builder.GetInsertBlock()->getModule()->getDataLayout();
94789478
Type *IndexTy = State.VF.isScalable() && (isReverse() || Part > 0)
9479-
? DL.getIndexType(ScalarDataTy->getPointerTo())
9479+
? DL.getIndexType(PointerType::getUnqual(
9480+
ScalarDataTy->getContext()))
94809481
: Builder.getInt32Ty();
94819482
bool InBounds = false;
94829483
if (auto *gep = dyn_cast<GetElementPtrInst>(Ptr->stripPointerCasts()))

0 commit comments

Comments
 (0)