Skip to content

Commit 416f1c4

Browse files
authored
[IR] Replace of PointerType::get(Type) with opaque version (NFC) (#123617)
In accordance with #123569 In order to keep the patch at reasonable size, this PR only covers for the llvm subproject, unittests excluded.
1 parent 9c7e02d commit 416f1c4

39 files changed

+76
-92
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
223223
//
224224
// First, compute the cost of the individual memory operations.
225225
InstructionCost AddrExtractCost =
226-
IsGatherScatter
227-
? getScalarizationOverhead(
228-
FixedVectorType::get(
229-
PointerType::get(VT->getElementType(), 0), VF),
230-
/*Insert=*/false, /*Extract=*/true, CostKind)
231-
: 0;
226+
IsGatherScatter ? getScalarizationOverhead(
227+
FixedVectorType::get(
228+
PointerType::get(VT->getContext(), 0), VF),
229+
/*Insert=*/false, /*Extract=*/true, CostKind)
230+
: 0;
232231

233232
// The cost of the scalar loads/stores.
234233
InstructionCost MemoryOpCost =

llvm/include/llvm/IR/GlobalValue.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class GlobalValue : public Constant {
7979
protected:
8080
GlobalValue(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage,
8181
const Twine &Name, unsigned AddressSpace)
82-
: Constant(PointerType::get(Ty, AddressSpace), VTy, AllocInfo),
82+
: Constant(PointerType::get(Ty->getContext(), AddressSpace), VTy,
83+
AllocInfo),
8384
ValueType(Ty), Visibility(DefaultVisibility),
8485
UnnamedAddrVal(unsigned(UnnamedAddr::None)),
8586
DllStorageClass(DefaultStorageClass), ThreadLocal(NotThreadLocal),

llvm/include/llvm/SandboxIR/Type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ class Type {
291291
class PointerType : public Type {
292292
public:
293293
// TODO: add missing functions
294+
295+
// TODO: Remove non-opaque variant of sandboxir::PointerType::get
294296
static PointerType *get(Type *ElementType, unsigned AddressSpace);
295297
static PointerType *get(Context &Ctx, unsigned AddressSpace);
296298

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,7 @@ Error BitcodeReader::parseTypeTableBody() {
25982598
!PointerType::isValidElementType(ResultTy))
25992599
return error("Invalid type");
26002600
ContainedIDs.push_back(Record[0]);
2601-
ResultTy = PointerType::get(ResultTy, AddressSpace);
2601+
ResultTy = PointerType::get(ResultTy->getContext(), AddressSpace);
26022602
break;
26032603
}
26042604
case bitc::TYPE_CODE_OPAQUE_POINTER: { // OPAQUE_POINTER: [addrspace]

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ void CallLowering::insertSRetIncomingArgument(
10541054
DemoteReg = MRI.createGenericVirtualRegister(
10551055
LLT::pointer(AS, DL.getPointerSizeInBits(AS)));
10561056

1057-
Type *PtrTy = PointerType::get(F.getReturnType(), AS);
1057+
Type *PtrTy = PointerType::get(F.getContext(), AS);
10581058

10591059
SmallVector<EVT, 1> ValueVTs;
10601060
ComputeValueVTs(*TLI, DL, PtrTy, ValueVTs);
@@ -1081,7 +1081,7 @@ void CallLowering::insertSRetOutgoingArgument(MachineIRBuilder &MIRBuilder,
10811081
DL.getTypeAllocSize(RetTy), DL.getPrefTypeAlign(RetTy), false);
10821082

10831083
Register DemoteReg = MIRBuilder.buildFrameIndex(FramePtrTy, FI).getReg(0);
1084-
ArgInfo DemoteArg(DemoteReg, PointerType::get(RetTy, AS),
1084+
ArgInfo DemoteArg(DemoteReg, PointerType::get(RetTy->getContext(), AS),
10851085
ArgInfo::NoArgIndex);
10861086
setArgFlags(DemoteArg, AttributeList::ReturnIndex, DL, CB);
10871087
DemoteArg.Flags[0].setSRet();

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11004,8 +11004,8 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
1100411004
MachineFunction &MF = CLI.DAG.getMachineFunction();
1100511005
DemoteStackIdx =
1100611006
MF.getFrameInfo().CreateStackObject(TySize, Alignment, false);
11007-
Type *StackSlotPtrType = PointerType::get(CLI.RetTy,
11008-
DL.getAllocaAddrSpace());
11007+
Type *StackSlotPtrType =
11008+
PointerType::get(CLI.RetTy->getContext(), DL.getAllocaAddrSpace());
1100911009

1101011010
DemoteStackSlot = CLI.DAG.getFrameIndex(DemoteStackIdx, getFrameIndexTy(DL));
1101111011
ArgListEntry Entry;

llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ createLocalIndirectStubsManagerBuilder(const Triple &T) {
273273
Constant* createIRTypedAddress(FunctionType &FT, ExecutorAddr Addr) {
274274
Constant *AddrIntVal =
275275
ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr.getValue());
276-
Constant *AddrPtrVal =
277-
ConstantExpr::getIntToPtr(AddrIntVal, PointerType::get(&FT, 0));
276+
Constant *AddrPtrVal = ConstantExpr::getIntToPtr(
277+
AddrIntVal, PointerType::get(FT.getContext(), 0));
278278
return AddrPtrVal;
279279
}
280280

llvm/lib/FuzzMutate/RandomIRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Instruction *RandomIRBuilder::newSink(BasicBlock &BB,
370370
Type *Ty = V->getType();
371371
Ptr = createStackMemory(BB.getParent(), Ty, PoisonValue::get(Ty));
372372
} else {
373-
Ptr = PoisonValue::get(PointerType::get(V->getType(), 0));
373+
Ptr = PoisonValue::get(PointerType::get(V->getContext(), 0));
374374
}
375375
}
376376

llvm/lib/IR/Core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount) {
873873
}
874874

875875
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) {
876-
return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
876+
return wrap(
877+
PointerType::get(unwrap(ElementType)->getContext(), AddressSpace));
877878
}
878879

879880
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) {

llvm/lib/IR/Instructions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
12141214
AllocaInst::AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize,
12151215
Align Align, const Twine &Name,
12161216
InsertPosition InsertBefore)
1217-
: UnaryInstruction(PointerType::get(Ty, AddrSpace), Alloca,
1217+
: UnaryInstruction(PointerType::get(Ty->getContext(), AddrSpace), Alloca,
12181218
getAISize(Ty->getContext(), ArraySize), InsertBefore),
12191219
AllocatedType(Ty) {
12201220
setAlignment(Align);

0 commit comments

Comments
 (0)