[llvm] e5026f0 - [llvm] Remove uses of Type::getPointerTo() (NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 16:45:10 PDT 2023
Author: Youngsuk Kim
Date: 2023-09-22T19:44:38-04:00
New Revision: e5026f0179f2871ba9fefc489972643324a4ba4f
URL: https://github.com/llvm/llvm-project/commit/e5026f0179f2871ba9fefc489972643324a4ba4f
DIFF: https://github.com/llvm/llvm-project/commit/e5026f0179f2871ba9fefc489972643324a4ba4f.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index aa286d5f55d615e..f19beea3a3ed8b7 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -2251,7 +2251,7 @@ SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
// Also pass the return address of the remainder.
SDValue FIPtr = DAG.CreateStackTemporary(RetVT);
Entry.Node = FIPtr;
- Entry.Ty = RetTy->getPointerTo();
+ Entry.Ty = PointerType::getUnqual(RetTy->getContext());
Entry.IsSExt = isSigned;
Entry.IsZExt = !isSigned;
Args.push_back(Entry);
@@ -2342,7 +2342,7 @@ SelectionDAGLegalize::ExpandSinCosLibCall(SDNode *Node,
// Pass the return address of sin.
SDValue SinPtr = DAG.CreateStackTemporary(RetVT);
Entry.Node = SinPtr;
- Entry.Ty = RetTy->getPointerTo();
+ Entry.Ty = PointerType::getUnqual(RetTy->getContext());
Entry.IsSExt = false;
Entry.IsZExt = false;
Args.push_back(Entry);
@@ -2350,7 +2350,7 @@ SelectionDAGLegalize::ExpandSinCosLibCall(SDNode *Node,
// Also pass the return address of the cos.
SDValue CosPtr = DAG.CreateStackTemporary(RetVT);
Entry.Node = CosPtr;
- Entry.Ty = RetTy->getPointerTo();
+ Entry.Ty = PointerType::getUnqual(RetTy->getContext());
Entry.IsSExt = false;
Entry.IsZExt = false;
Args.push_back(Entry);
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index f57c8693e4996bc..304edc2c3a2c374 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -2853,9 +2853,7 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
auto *VecTy = cast<FixedVectorType>(CI->getType());
Type *EltTy = VecTy->getElementType();
unsigned EltNum = VecTy->getNumElements();
- Value *Cast = Builder.CreateBitCast(CI->getArgOperand(0),
- EltTy->getPointerTo());
- Value *Load = Builder.CreateLoad(EltTy, Cast);
+ Value *Load = Builder.CreateLoad(EltTy, CI->getArgOperand(0));
Type *I32Ty = Type::getInt32Ty(C);
Rep = PoisonValue::get(VecTy);
for (unsigned I = 0; I < EltNum; ++I)
diff --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index b2a55219df06ac2..aa12e9d513d4fad 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -706,7 +706,8 @@ auto AlignVectors::createAlignedPointer(IRBuilderBase &Builder, Value *Ptr,
Value *AsInt = Builder.CreatePtrToInt(Ptr, HVC.getIntTy(), "pti");
Value *Mask = HVC.getConstInt(-Alignment);
Value *And = Builder.CreateAnd(remap(AsInt), Mask, "and");
- return Builder.CreateIntToPtr(And, ValTy->getPointerTo(), "itp");
+ return Builder.CreateIntToPtr(
+ And, PointerType::getUnqual(ValTy->getContext()), "itp");
}
auto AlignVectors::createLoad(IRBuilderBase &Builder, Type *ValTy, Value *Ptr,
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 98c41c6741310e9..d838d1f96e310d8 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -5760,8 +5760,8 @@ InstructionCost X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy,
}
InstructionCost AddressUnpackCost = getScalarizationOverhead(
- FixedVectorType::get(ScalarTy->getPointerTo(), VF), DemandedElts,
- /*Insert=*/false, /*Extract=*/true, CostKind);
+ FixedVectorType::get(PointerType::getUnqual(ScalarTy->getContext()), VF),
+ DemandedElts, /*Insert=*/false, /*Extract=*/true, CostKind);
// The cost of the scalar loads/stores.
InstructionCost MemoryOpCost =
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index c90692980d86ac5..027f303c521900a 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -190,7 +190,8 @@ class PGOCounterPromoterHelper : public LoadAndStorePromoter {
auto *OrigBiasInst = dyn_cast<BinaryOperator>(AddrInst->getOperand(0));
assert(OrigBiasInst->getOpcode() == Instruction::BinaryOps::Add);
Value *BiasInst = Builder.Insert(OrigBiasInst->clone());
- Addr = Builder.CreateIntToPtr(BiasInst, Ty->getPointerTo());
+ Addr = Builder.CreateIntToPtr(BiasInst,
+ PointerType::getUnqual(Ty->getContext()));
}
if (AtomicCounterUpdatePromoted)
// automic update currently can only be promoted across the current
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 56b768945cd6fca..9b476a44988fccc 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -3379,12 +3379,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
IRBuilder<> IRB(&I);
Value *Addr = I.getArgOperand(0);
Type *Ty = IRB.getInt32Ty();
- Type *PtrTy = IRB.getPtrTy();
Value *ShadowPtr =
getShadowOriginPtr(Addr, IRB, Ty, Align(1), /*isStore*/ true).first;
- IRB.CreateStore(getCleanShadow(Ty),
- IRB.CreatePointerCast(ShadowPtr, PtrTy));
+ IRB.CreateStore(getCleanShadow(Ty), ShadowPtr);
if (ClCheckAccessAddress)
insertShadowCheck(Addr, &I);
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 8da5692f1ee89c2..ee75eb69af777a7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9476,7 +9476,8 @@ void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
const DataLayout &DL =
Builder.GetInsertBlock()->getModule()->getDataLayout();
Type *IndexTy = State.VF.isScalable() && (isReverse() || Part > 0)
- ? DL.getIndexType(ScalarDataTy->getPointerTo())
+ ? DL.getIndexType(PointerType::getUnqual(
+ ScalarDataTy->getContext()))
: Builder.getInt32Ty();
bool InBounds = false;
if (auto *gep = dyn_cast<GetElementPtrInst>(Ptr->stripPointerCasts()))
More information about the llvm-commits
mailing list