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);

llvm/lib/IR/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ PointerType::PointerType(LLVMContext &C, unsigned AddrSpace)
857857
}
858858

859859
PointerType *Type::getPointerTo(unsigned AddrSpace) const {
860-
return PointerType::get(const_cast<Type*>(this), AddrSpace);
860+
return PointerType::get(getContext(), AddrSpace);
861861
}
862862

863863
bool PointerType::isValidElementType(Type *ElemTy) {

llvm/lib/Linker/IRMover.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,6 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
296296
case Type::FixedVectorTyID:
297297
return *Entry = VectorType::get(ElementTypes[0],
298298
cast<VectorType>(Ty)->getElementCount());
299-
case Type::PointerTyID:
300-
return *Entry = PointerType::get(ElementTypes[0],
301-
cast<PointerType>(Ty)->getAddressSpace());
302299
case Type::FunctionTyID:
303300
return *Entry = FunctionType::get(ElementTypes[0],
304301
ArrayRef(ElementTypes).slice(1),

llvm/lib/SandboxIR/Type.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ void Type::dump() {
4646
#endif
4747

4848
PointerType *PointerType::get(Type *ElementType, unsigned AddressSpace) {
49-
return cast<PointerType>(ElementType->getContext().getType(
50-
llvm::PointerType::get(ElementType->LLVMTy, AddressSpace)));
49+
return get(ElementType->getContext(), AddressSpace);
5150
}
5251

5352
PointerType *PointerType::get(Context &Ctx, unsigned AddressSpace) {

llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,9 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
793793
VoidTy = Type::getVoidTy(M->getContext());
794794

795795
GuardFnType = FunctionType::get(PtrTy, {PtrTy, PtrTy}, false);
796-
GuardFnPtrType = PointerType::get(GuardFnType, 0);
796+
GuardFnPtrType = PointerType::get(M->getContext(), 0);
797797
DispatchFnType = FunctionType::get(PtrTy, {PtrTy, PtrTy, PtrTy}, false);
798-
DispatchFnPtrType = PointerType::get(DispatchFnType, 0);
798+
DispatchFnPtrType = PointerType::get(M->getContext(), 0);
799799
GuardFnCFGlobal =
800800
M->getOrInsertGlobal("__os_arm64x_check_icall_cfg", GuardFnPtrType);
801801
GuardFnGlobal =

llvm/lib/Target/AMDGPU/AMDGPUAsanInstrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void instrumentAddressImpl(Module &M, IRBuilder<> &IRB,
161161
size_t AccessSizeIndex = TypeStoreSizeToSizeIndex(TypeStoreSize);
162162
Type *ShadowTy = IntegerType::get(M.getContext(),
163163
std::max(8U, TypeStoreSize >> AsanScale));
164-
Type *ShadowPtrTy = PointerType::get(ShadowTy, 0);
164+
Type *ShadowPtrTy = PointerType::get(M.getContext(), 0);
165165
Value *AddrLong = IRB.CreatePtrToInt(Addr, IntptrTy);
166166
Value *ShadowPtr =
167167
memToShadow(M, IRB, IntptrTy, AddrLong, AsanScale, AsanOffset);

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
277277

278278
Type *Tys_alloc[1] = {SizetTy};
279279
Type *I8Ty = Type::getInt8Ty(Ctx);
280-
Type *I8Ptr = PointerType::get(I8Ty, 1);
280+
Type *I8Ptr = PointerType::get(Ctx, 1);
281281
FunctionType *FTy_alloc = FunctionType::get(I8Ptr, Tys_alloc, false);
282282
FunctionCallee PrintfAllocFn =
283283
M.getOrInsertFunction(StringRef("__printf_alloc"), FTy_alloc, Attr);
@@ -300,7 +300,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
300300
// basicblock splits after buffer overflow check
301301
//
302302
ConstantPointerNull *zeroIntPtr =
303-
ConstantPointerNull::get(PointerType::get(I8Ty, 1));
303+
ConstantPointerNull::get(PointerType::get(Ctx, 1));
304304
auto *cmp = cast<ICmpInst>(Builder.CreateICmpNE(pcall, zeroIntPtr, ""));
305305
if (!CI->use_empty()) {
306306
Value *result =
@@ -320,7 +320,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
320320
I8Ty, pcall, ConstantInt::get(Ctx, APInt(32, 0)), "PrintBuffID",
321321
BrnchPoint);
322322

323-
Type *idPointer = PointerType::get(I32Ty, AMDGPUAS::GLOBAL_ADDRESS);
323+
Type *idPointer = PointerType::get(Ctx, AMDGPUAS::GLOBAL_ADDRESS);
324324
Value *id_gep_cast =
325325
new BitCastInst(BufferIdx, idPointer, "PrintBuffIdCast", BrnchPoint);
326326

llvm/lib/Target/AMDGPU/R600ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ SDValue R600TargetLowering::LowerImplicitParameter(SelectionDAG &DAG, EVT VT,
762762
const SDLoc &DL,
763763
unsigned DwordOffset) const {
764764
unsigned ByteOffset = DwordOffset * 4;
765-
PointerType * PtrType = PointerType::get(VT.getTypeForEVT(*DAG.getContext()),
766-
AMDGPUAS::PARAM_I_ADDRESS);
765+
PointerType *PtrType =
766+
PointerType::get(*DAG.getContext(), AMDGPUAS::PARAM_I_ADDRESS);
767767

768768
// We shouldn't be using an offset wider than 16-bits for implicit parameters.
769769
assert(isInt<16>(ByteOffset));

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7819,7 +7819,8 @@ SDValue SITargetLowering::LowerGlobalAddress(AMDGPUMachineFunction *MFI,
78197819
SIInstrInfo::MO_GOTPCREL32);
78207820

78217821
Type *Ty = PtrVT.getTypeForEVT(*DAG.getContext());
7822-
PointerType *PtrTy = PointerType::get(Ty, AMDGPUAS::CONSTANT_ADDRESS);
7822+
PointerType *PtrTy =
7823+
PointerType::get(*DAG.getContext(), AMDGPUAS::CONSTANT_ADDRESS);
78237824
const DataLayout &DataLayout = DAG.getDataLayout();
78247825
Align Alignment = DataLayout.getABITypeAlign(PtrTy);
78257826
MachinePointerInfo PtrInfo =

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ static Value *simplifyNeonVld1(const IntrinsicInst &II, unsigned MemAlign,
8383
if (!isPowerOf2_32(Alignment))
8484
return nullptr;
8585

86-
auto *BCastInst = Builder.CreateBitCast(II.getArgOperand(0),
87-
PointerType::get(II.getType(), 0));
88-
return Builder.CreateAlignedLoad(II.getType(), BCastInst, Align(Alignment));
86+
return Builder.CreateAlignedLoad(II.getType(), II.getArgOperand(0),
87+
Align(Alignment));
8988
}
9089

9190
bool ARMTTIImpl::areInlineCompatible(const Function *Caller,

llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ Value *GenericToNVVM::remapConstant(Module *M, Function *F, Constant *C,
154154
if (I != GVMap.end()) {
155155
GlobalVariable *GV = I->second;
156156
NewValue = Builder.CreateAddrSpaceCast(
157-
GV,
158-
PointerType::get(GV->getValueType(), llvm::ADDRESS_SPACE_GENERIC));
157+
GV, PointerType::get(GV->getContext(), llvm::ADDRESS_SPACE_GENERIC));
159158
}
160159
} else if (isa<ConstantAggregate>(C)) {
161160
// If any element in the constant vector or aggregate C is or uses a global

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,8 +2804,8 @@ SDValue NVPTXTargetLowering::LowerVAARG(SDValue Op, SelectionDAG &DAG) const {
28042804
Tmp1 = DAG.getStore(VAListLoad.getValue(1), DL, Tmp1, Tmp2,
28052805
MachinePointerInfo(V));
28062806

2807-
const Value *SrcV =
2808-
Constant::getNullValue(PointerType::get(Ty, ADDRESS_SPACE_LOCAL));
2807+
const Value *SrcV = Constant::getNullValue(
2808+
PointerType::get(*DAG.getContext(), ADDRESS_SPACE_LOCAL));
28092809

28102810
// Load the actual argument out of the pointer VAList
28112811
return DAG.getLoad(VT, DL, Tmp1, VAList, MachinePointerInfo(SrcV));
@@ -3194,8 +3194,8 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
31943194
SDValue VecAddr =
31953195
DAG.getNode(ISD::ADD, dl, PtrVT, Arg,
31963196
DAG.getConstant(Offsets[VecIdx], dl, PtrVT));
3197-
Value *srcValue = Constant::getNullValue(PointerType::get(
3198-
EltVT.getTypeForEVT(F->getContext()), ADDRESS_SPACE_PARAM));
3197+
Value *srcValue = Constant::getNullValue(
3198+
PointerType::get(F->getContext(), ADDRESS_SPACE_PARAM));
31993199

32003200
const MaybeAlign PartAlign = [&]() -> MaybeAlign {
32013201
if (aggregateIsPacked)

llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ bool NVPTXLowerAlloca::runOnFunction(Function &F) {
9090
// addrspacecast to ADDRESS_SPACE_GENERIC.
9191
if (AllocAddrSpace == ADDRESS_SPACE_GENERIC) {
9292
auto ASCastToLocalAS = new AddrSpaceCastInst(
93-
allocaInst, PointerType::get(ETy, ADDRESS_SPACE_LOCAL), "");
93+
allocaInst,
94+
PointerType::get(ETy->getContext(), ADDRESS_SPACE_LOCAL), "");
9495
ASCastToLocalAS->insertAfter(allocaInst);
9596
AllocaInLocalAS = ASCastToLocalAS;
9697
}
9798

9899
auto AllocaInGenericAS = new AddrSpaceCastInst(
99-
AllocaInLocalAS, PointerType::get(ETy, ADDRESS_SPACE_GENERIC), "");
100+
AllocaInLocalAS,
101+
PointerType::get(ETy->getContext(), ADDRESS_SPACE_GENERIC), "");
100102
AllocaInGenericAS->insertAfter(AllocaInLocalAS);
101103

102104
for (Use &AllocaUse : llvm::make_early_inc_range(allocaInst->uses())) {

llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ void NVPTXLowerArgs::handleByValParam(const NVPTXTargetMachine &TM,
594594
UsesToUpdate.push_back(&U);
595595

596596
Value *ArgInParamAS = new AddrSpaceCastInst(
597-
Arg, PointerType::get(StructType, ADDRESS_SPACE_PARAM), Arg->getName(),
598-
FirstInst);
597+
Arg, PointerType::get(StructType->getContext(), ADDRESS_SPACE_PARAM),
598+
Arg->getName(), FirstInst);
599599
for (Use *U : UsesToUpdate)
600600
convertToParamAS(U, ArgInParamAS, HasCvtaParam, IsGridConstant);
601601
LLVM_DEBUG(dbgs() << "No need to copy or cast " << *Arg << "\n");

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29644,7 +29644,7 @@ SDValue X86TargetLowering::LowerWin64_i128OP(SDValue Op, SelectionDAG &DAG) cons
2964429644
InChain =
2964529645
DAG.getStore(InChain, dl, Op->getOperand(i), StackPtr, MPI, Align(16));
2964629646
Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext());
29647-
Entry.Ty = PointerType::get(ArgTy,0);
29647+
Entry.Ty = PointerType::get(*DAG.getContext(), 0);
2964829648
Entry.IsSExt = false;
2964929649
Entry.IsZExt = false;
2965029650
Args.push_back(Entry);

llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,9 @@ static Instruction *simplifyX86MaskedLoad(IntrinsicInst &II, InstCombiner &IC) {
6767
// The mask is constant or extended from a bool vector. Convert this x86
6868
// intrinsic to the LLVM intrinsic to allow target-independent optimizations.
6969
if (Value *BoolMask = getBoolVecFromMask(Mask, IC.getDataLayout())) {
70-
// First, cast the x86 intrinsic scalar pointer to a vector pointer to match
71-
// the LLVM intrinsic definition for the pointer argument.
72-
unsigned AddrSpace = cast<PointerType>(Ptr->getType())->getAddressSpace();
73-
PointerType *VecPtrTy = PointerType::get(II.getType(), AddrSpace);
74-
Value *PtrCast = IC.Builder.CreateBitCast(Ptr, VecPtrTy, "castvec");
75-
7670
// The pass-through vector for an x86 masked load is a zero vector.
7771
CallInst *NewMaskedLoad = IC.Builder.CreateMaskedLoad(
78-
II.getType(), PtrCast, Align(1), BoolMask, ZeroVec);
72+
II.getType(), Ptr, Align(1), BoolMask, ZeroVec);
7973
return IC.replaceInstUsesWith(II, NewMaskedLoad);
8074
}
8175

@@ -105,7 +99,7 @@ static bool simplifyX86MaskedStore(IntrinsicInst &II, InstCombiner &IC) {
10599
// intrinsic to the LLVM intrinsic to allow target-independent optimizations.
106100
if (Value *BoolMask = getBoolVecFromMask(Mask, IC.getDataLayout())) {
107101
unsigned AddrSpace = cast<PointerType>(Ptr->getType())->getAddressSpace();
108-
PointerType *VecPtrTy = PointerType::get(Vec->getType(), AddrSpace);
102+
PointerType *VecPtrTy = PointerType::get(Vec->getContext(), AddrSpace);
109103
Value *PtrCast = IC.Builder.CreateBitCast(Ptr, VecPtrTy, "castvec");
110104

111105
IC.Builder.CreateMaskedStore(Vec, PtrCast, Align(1), BoolMask);

llvm/lib/Transforms/CFGuard/CFGuard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ bool CFGuardImpl::doInitialization(Module &M) {
247247
GuardFnType =
248248
FunctionType::get(Type::getVoidTy(M.getContext()),
249249
{PointerType::getUnqual(M.getContext())}, false);
250-
GuardFnPtrType = PointerType::get(GuardFnType, 0);
250+
GuardFnPtrType = PointerType::get(M.getContext(), 0);
251251

252252
GuardFnGlobal = M.getOrInsertGlobal(GuardFnName, GuardFnPtrType, [&] {
253253
auto *Var = new GlobalVariable(M, GuardFnPtrType, false,

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12344,7 +12344,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
1234412344
ChangeStatus Changed = ChangeStatus::UNCHANGED;
1234512345
Value *FP = CB->getCalledOperand();
1234612346
if (FP->getType()->getPointerAddressSpace())
12347-
FP = new AddrSpaceCastInst(FP, PointerType::get(FP->getType(), 0),
12347+
FP = new AddrSpaceCastInst(FP, PointerType::get(FP->getContext(), 0),
1234812348
FP->getName() + ".as0", CB->getIterator());
1234912349

1235012350
bool CBIsVoid = CB->getType()->isVoidTy();

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,8 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
10351035
RuntimeCallInserter &RTCI)
10361036
: F(F), ASan(ASan), RTCI(RTCI),
10371037
DIB(*F.getParent(), /*AllowUnresolved*/ false), C(ASan.C),
1038-
IntptrTy(ASan.IntptrTy), IntptrPtrTy(PointerType::get(IntptrTy, 0)),
1038+
IntptrTy(ASan.IntptrTy),
1039+
IntptrPtrTy(PointerType::get(IntptrTy->getContext(), 0)),
10391040
Mapping(ASan.Mapping),
10401041
PoisonStack(ClStack &&
10411042
!Triple(F.getParent()->getTargetTriple()).isAMDGPU()) {}
@@ -1882,7 +1883,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
18821883

18831884
Type *ShadowTy =
18841885
IntegerType::get(*C, std::max(8U, TypeStoreSize >> Mapping.Scale));
1885-
Type *ShadowPtrTy = PointerType::get(ShadowTy, 0);
1886+
Type *ShadowPtrTy = PointerType::get(*C, 0);
18861887
Value *ShadowPtr = memToShadow(AddrLong, IRB);
18871888
const uint64_t ShadowAlign =
18881889
std::max<uint64_t>(Alignment.valueOrOne().value() >> Mapping.Scale, 1);

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,13 +1790,12 @@ Value *DFSanFunction::getArgTLS(Type *T, unsigned ArgOffset, IRBuilder<> &IRB) {
17901790
Value *Base = IRB.CreatePointerCast(DFS.ArgTLS, DFS.IntptrTy);
17911791
if (ArgOffset)
17921792
Base = IRB.CreateAdd(Base, ConstantInt::get(DFS.IntptrTy, ArgOffset));
1793-
return IRB.CreateIntToPtr(Base, PointerType::get(DFS.getShadowTy(T), 0),
1794-
"_dfsarg");
1793+
return IRB.CreateIntToPtr(Base, PointerType::get(*DFS.Ctx, 0), "_dfsarg");
17951794
}
17961795

17971796
Value *DFSanFunction::getRetvalTLS(Type *T, IRBuilder<> &IRB) {
1798-
return IRB.CreatePointerCast(
1799-
DFS.RetvalTLS, PointerType::get(DFS.getShadowTy(T), 0), "_dfsret");
1797+
return IRB.CreatePointerCast(DFS.RetvalTLS, PointerType::get(*DFS.Ctx, 0),
1798+
"_dfsret");
18001799
}
18011800

18021801
Value *DFSanFunction::getRetvalOriginTLS() { return DFS.RetvalOriginTLS; }
@@ -1926,8 +1925,7 @@ DataFlowSanitizer::getShadowOriginAddress(Value *Addr, Align InstAlignment,
19261925
IRB.CreateAdd(ShadowLong, ConstantInt::get(IntptrTy, ShadowBase));
19271926
}
19281927
IntegerType *ShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
1929-
Value *ShadowPtr =
1930-
IRB.CreateIntToPtr(ShadowLong, PointerType::get(ShadowTy, 0));
1928+
Value *ShadowPtr = IRB.CreateIntToPtr(ShadowLong, PointerType::get(*Ctx, 0));
19311929
Value *OriginPtr = nullptr;
19321930
if (shouldTrackOrigins()) {
19331931
Value *OriginLong = ShadowOffset;
@@ -2491,8 +2489,8 @@ void DFSanFunction::paintOrigin(IRBuilder<> &IRB, Value *Origin,
24912489
Align CurrentAlignment = Alignment;
24922490
if (Alignment >= IntptrAlignment && IntptrSize > OriginSize) {
24932491
Value *IntptrOrigin = originToIntptr(IRB, Origin);
2494-
Value *IntptrStoreOriginPtr = IRB.CreatePointerCast(
2495-
StoreOriginAddr, PointerType::get(DFS.IntptrTy, 0));
2492+
Value *IntptrStoreOriginPtr =
2493+
IRB.CreatePointerCast(StoreOriginAddr, PointerType::get(*DFS.Ctx, 0));
24962494
for (unsigned I = 0; I < StoreOriginSize / IntptrSize; ++I) {
24972495
Value *Ptr =
24982496
I ? IRB.CreateConstGEP1_32(DFS.IntptrTy, IntptrStoreOriginPtr, I)

0 commit comments

Comments
 (0)