[llvm] [llvm] Replace uses of Type::getPointerTo() (NFC) (PR #110163)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 13:28:58 PDT 2024
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/110163
>From e1543513e8db2016ede98426b97e374bb3583bef Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Thu, 26 Sep 2024 14:48:55 -0500
Subject: [PATCH 1/2] [llvm] Replace uses of Type::getPointerTo() (NFC)
Replace uses of `Type::getPointerTo()` which is to be removed.
---
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 3 ++-
llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp | 5 ++---
llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 4 ++--
llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 4 ++--
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 513914d3218fbc..9f9a1bb89103f4 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -1034,7 +1034,8 @@ void CallLowering::insertSRetStores(MachineIRBuilder &MIRBuilder, Type *RetTy,
unsigned NumValues = SplitVTs.size();
Align BaseAlign = DL.getPrefTypeAlign(RetTy);
unsigned AS = DL.getAllocaAddrSpace();
- LLT OffsetLLTy = getLLTForType(*DL.getIndexType(RetTy->getPointerTo(AS)), DL);
+ LLT OffsetLLTy = getLLTForType(
+ *DL.getIndexType(PointerType::get(RetTy->getContext(), AS)), DL);
MachinePointerInfo PtrInfo(AS);
diff --git a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
index 2b78ed7134c92f..660e00b893c885 100644
--- a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
+++ b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
@@ -440,7 +440,7 @@ static Value *aspaceWrapValue(DenseMap<Value *, Value *> &Cache, Function *F,
auto *GEPTy = cast<PointerType>(GEP->getType());
auto *NewGEP = GEP->clone();
NewGEP->insertAfter(GEP);
- NewGEP->mutateType(GEPTy->getPointerTo(0));
+ NewGEP->mutateType(PointerType::getUnqual(GEPTy->getContext()));
NewGEP->setOperand(GEP->getPointerOperandIndex(), WrappedPtr);
NewGEP->setName(GEP->getName());
Cache[ToWrap] = NewGEP;
@@ -452,8 +452,7 @@ static Value *aspaceWrapValue(DenseMap<Value *, Value *> &Cache, Function *F,
IB.SetInsertPoint(*InsnPtr->getInsertionPointAfterDef());
else
IB.SetInsertPoint(F->getEntryBlock().getFirstInsertionPt());
- auto *PtrTy = cast<PointerType>(ToWrap->getType());
- auto *ASZeroPtrTy = PtrTy->getPointerTo(0);
+ auto *ASZeroPtrTy = IB.getPtrTy(0);
auto *ACast = IB.CreateAddrSpaceCast(ToWrap, ASZeroPtrTy, ToWrap->getName());
Cache[ToWrap] = ACast;
return ACast;
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 0742b259c489c0..519a4e9314a26b 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1658,8 +1658,8 @@ void LowerTypeTestsModule::buildBitSetsFromFunctionsNative(
".cfi.jumptable", &M);
ArrayType *JumpTableType =
ArrayType::get(getJumpTableEntryType(), Functions.size());
- auto JumpTable =
- ConstantExpr::getPointerCast(JumpTableFn, JumpTableType->getPointerTo(0));
+ auto JumpTable = ConstantExpr::getPointerCast(
+ JumpTableFn, PointerType::getUnqual(M.getContext()));
lowerTypeTestCalls(TypeIds, JumpTable, GlobalLayout);
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 28da864cad0ffc..35664a5c7a2ac2 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3536,8 +3536,8 @@ struct AAHeapToSharedFunction : public AAHeapToShared {
PoisonValue::get(Int8ArrTy), CB->getName() + "_shared", nullptr,
GlobalValue::NotThreadLocal,
static_cast<unsigned>(AddressSpace::Shared));
- auto *NewBuffer =
- ConstantExpr::getPointerCast(SharedMem, Int8Ty->getPointerTo());
+ auto *NewBuffer = ConstantExpr::getPointerCast(
+ SharedMem, PointerType::getUnqual(M->getContext()));
auto Remark = [&](OptimizationRemark OR) {
return OR << "Replaced globalized variable with "
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 18116b5701fe19..2f0ba5510b8f34 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1743,7 +1743,7 @@ void VPVectorPointerRecipe ::execute(VPTransformState &State) {
// or query DataLayout for a more suitable index type otherwise.
const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout();
Type *IndexTy = State.VF.isScalable() && (IsReverse || CurrentPart > 0)
- ? DL.getIndexType(IndexedTy->getPointerTo())
+ ? DL.getIndexType(Builder.getPtrTy(0))
: Builder.getInt32Ty();
Value *Ptr = State.get(getOperand(0), VPLane(0));
bool InBounds = isInBounds();
>From 59de3a2a07b8f12b53d36e3e38389a5890882abf Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <joseph942010 at gmail.com>
Date: Thu, 26 Sep 2024 16:28:50 -0400
Subject: [PATCH 2/2] Use other variant of DataLayout::getIndexType()
apply nikic's feedback
Co-authored-by: Nikita Popov <github at npopov.com>
---
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 9f9a1bb89103f4..3e25e2a74d6890 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -1035,7 +1035,7 @@ void CallLowering::insertSRetStores(MachineIRBuilder &MIRBuilder, Type *RetTy,
Align BaseAlign = DL.getPrefTypeAlign(RetTy);
unsigned AS = DL.getAllocaAddrSpace();
LLT OffsetLLTy = getLLTForType(
- *DL.getIndexType(PointerType::get(RetTy->getContext(), AS)), DL);
+ *DL.getIndexType(RetTy->getContext(), AS), DL);
MachinePointerInfo PtrInfo(AS);
More information about the llvm-commits
mailing list