Skip to content

Commit d7c14c8

Browse files
authored
[IR] Replace of PointerType::getUnqual(Type) with opaque version (NFC) (llvm#123909)
Follow up to llvm#123569
1 parent 7781381 commit d7c14c8

File tree

21 files changed

+41
-75
lines changed

21 files changed

+41
-75
lines changed

llvm/examples/BrainF/BrainF.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ void BrainF::header(LLVMContext& C) {
149149

150150
//declare i32 @puts(i8 *)
151151
FunctionCallee puts_func = module->getOrInsertFunction(
152-
"puts", IntegerType::getInt32Ty(C),
153-
PointerType::getUnqual(IntegerType::getInt8Ty(C)));
152+
"puts", IntegerType::getInt32Ty(C), PointerType::getUnqual(C));
154153

155154
//brainf.aberror:
156155
aberrorbb = BasicBlock::Create(C, label, brainf_func);
@@ -296,8 +295,8 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
296295
builder->SetInsertPoint(bb_1);
297296

298297
// Make part of PHI instruction now, wait until end of loop to finish
299-
PHINode *phi_0 = PHINode::Create(PointerType::getUnqual(Int8Ty), 2,
300-
headreg, testbb);
298+
PHINode *phi_0 =
299+
PHINode::Create(PointerType::getUnqual(C), 2, headreg, testbb);
301300
phi_0->addIncoming(curhead, bb_0);
302301
curhead = phi_0;
303302

@@ -451,7 +450,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
451450

452451
//%head.%d = phi i8 *[%head.%d, %main.%d]
453452
PHINode *phi_1 =
454-
builder->CreatePHI(PointerType::getUnqual(Int8Ty), 1, headreg);
453+
builder->CreatePHI(PointerType::getUnqual(C), 1, headreg);
455454
phi_1->addIncoming(head_0, testbb);
456455
curhead = phi_1;
457456
}

llvm/include/llvm/FuzzMutate/OpDescriptor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ static inline SourcePred anyPtrType() {
155155
std::vector<Constant *> Result;
156156
// TODO: Should these point at something?
157157
for (Type *T : Ts)
158-
Result.push_back(PoisonValue::get(PointerType::getUnqual(T)));
158+
Result.push_back(
159+
PoisonValue::get(PointerType::getUnqual(T->getContext())));
159160
return Result;
160161
};
161162
return {Pred, Make};
@@ -175,7 +176,8 @@ static inline SourcePred sizedPtrType() {
175176
// as the pointer type will always be the same.
176177
for (Type *T : Ts)
177178
if (T->isSized())
178-
Result.push_back(PoisonValue::get(PointerType::getUnqual(T)));
179+
Result.push_back(
180+
PoisonValue::get(PointerType::getUnqual(T->getContext())));
179181

180182
return Result;
181183
};

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13601,7 +13601,7 @@ const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {
1360113601
else
1360213602
return nullptr;
1360313603

13604-
Type *ETy = getEffectiveSCEVType(PointerType::getUnqual(Ty));
13604+
Type *ETy = getEffectiveSCEVType(PointerType::getUnqual(Inst->getContext()));
1360513605
return getSizeOfExpr(ETy, Ty);
1360613606
}
1360713607

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9005,10 +9005,6 @@ static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT,
90059005
Type::getIntNTy(PtrVal->getContext(), LoadVT.getScalarSizeInBits());
90069006
if (LoadVT.isVector())
90079007
LoadTy = FixedVectorType::get(LoadTy, LoadVT.getVectorNumElements());
9008-
9009-
LoadInput = ConstantExpr::getBitCast(const_cast<Constant *>(LoadInput),
9010-
PointerType::getUnqual(LoadTy));
9011-
90129008
if (const Constant *LoadCst =
90139009
ConstantFoldLoadFromConstPtr(const_cast<Constant *>(LoadInput),
90149010
LoadTy, Builder.DAG.getDataLayout()))

llvm/lib/CodeGen/ShadowStackGCLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ bool ShadowStackGCLoweringImpl::doInitialization(Module &M) {
233233
// Specifies length of variable length array.
234234
EltTys.push_back(Type::getInt32Ty(M.getContext()));
235235
FrameMapTy = StructType::create(EltTys, "gc_map");
236-
PointerType *FrameMapPtrTy = PointerType::getUnqual(FrameMapTy);
236+
PointerType *FrameMapPtrTy = PointerType::getUnqual(M.getContext());
237237

238238
// struct StackEntry {
239239
// ShadowStackEntry *Next; // Caller's stack entry.

llvm/lib/CodeGen/SjLjEHPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,10 @@ bool SjLjEHPrepareImpl::runOnFunction(Function &F) {
500500
Module &M = *F.getParent();
501501
RegisterFn = M.getOrInsertFunction(
502502
"_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()),
503-
PointerType::getUnqual(FunctionContextTy));
503+
PointerType::getUnqual(FunctionContextTy->getContext()));
504504
UnregisterFn = M.getOrInsertFunction(
505505
"_Unwind_SjLj_Unregister", Type::getVoidTy(M.getContext()),
506-
PointerType::getUnqual(FunctionContextTy));
506+
PointerType::getUnqual(FunctionContextTy->getContext()));
507507

508508
PointerType *AllocaPtrTy = M.getDataLayout().getAllocaPtrType(M.getContext());
509509

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
193193
{PlatformInstanceDecl, DSOHandle});
194194

195195
auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);
196-
auto *AtExitCallbackTy = FunctionType::get(VoidTy, {}, false);
197-
auto *AtExitCallbackPtrTy = PointerType::getUnqual(AtExitCallbackTy);
196+
auto *AtExitCallbackPtrTy = PointerType::getUnqual(*Ctx);
198197
auto *AtExit = addHelperAndWrapper(
199198
*M, "atexit", FunctionType::get(IntTy, {AtExitCallbackPtrTy}, false),
200199
GlobalValue::HiddenVisibility, "__lljit.atexit_helper",
@@ -468,12 +467,9 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
468467
*M, GenericIRPlatformSupportTy, true, GlobalValue::ExternalLinkage,
469468
nullptr, "__lljit.platform_support_instance");
470469

471-
auto *Int8Ty = Type::getInt8Ty(*Ctx);
472470
auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);
473-
auto *VoidTy = Type::getVoidTy(*Ctx);
474-
auto *BytePtrTy = PointerType::getUnqual(Int8Ty);
475-
auto *CxaAtExitCallbackTy = FunctionType::get(VoidTy, {BytePtrTy}, false);
476-
auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(CxaAtExitCallbackTy);
471+
auto *BytePtrTy = PointerType::getUnqual(*Ctx);
472+
auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(*Ctx);
477473

478474
auto *CxaAtExit = addHelperAndWrapper(
479475
*M, "__cxa_atexit",

llvm/lib/Frontend/Offloading/OffloadWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ StructType *getDeviceImageTy(Module &M) {
5050
}
5151

5252
PointerType *getDeviceImagePtrTy(Module &M) {
53-
return PointerType::getUnqual(getDeviceImageTy(M));
53+
return PointerType::getUnqual(M.getContext());
5454
}
5555

5656
// struct __tgt_bin_desc {
@@ -70,7 +70,7 @@ StructType *getBinDescTy(Module &M) {
7070
}
7171

7272
PointerType *getBinDescPtrTy(Module &M) {
73-
return PointerType::getUnqual(getBinDescTy(M));
73+
return PointerType::getUnqual(M.getContext());
7474
}
7575

7676
/// Creates binary descriptor for the given device images. Binary descriptor

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9177,16 +9177,16 @@ void OpenMPIRBuilder::initializeTypes(Module &M) {
91779177
#define OMP_TYPE(VarName, InitValue) VarName = InitValue;
91789178
#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) \
91799179
VarName##Ty = ArrayType::get(ElemTy, ArraySize); \
9180-
VarName##PtrTy = PointerType::getUnqual(VarName##Ty);
9180+
VarName##PtrTy = PointerType::getUnqual(Ctx);
91819181
#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) \
91829182
VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg); \
9183-
VarName##Ptr = PointerType::getUnqual(VarName);
9183+
VarName##Ptr = PointerType::getUnqual(Ctx);
91849184
#define OMP_STRUCT_TYPE(VarName, StructName, Packed, ...) \
91859185
T = StructType::getTypeByName(Ctx, StructName); \
91869186
if (!T) \
91879187
T = StructType::create(Ctx, {__VA_ARGS__}, StructName, Packed); \
91889188
VarName = T; \
9189-
VarName##Ptr = PointerType::getUnqual(T);
9189+
VarName##Ptr = PointerType::getUnqual(Ctx);
91909190
#include "llvm/Frontend/OpenMP/OMPKinds.def"
91919191
}
91929192

llvm/lib/IR/Constants.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,8 @@ Constant *ConstantExpr::getSizeOf(Type* Ty) {
24822482
// Note that a non-inbounds gep is used, as null isn't within any object.
24832483
Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
24842484
Constant *GEP = getGetElementPtr(
2485-
Ty, Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx);
2485+
Ty, Constant::getNullValue(PointerType::getUnqual(Ty->getContext())),
2486+
GEPIdx);
24862487
return getPtrToInt(GEP,
24872488
Type::getInt64Ty(Ty->getContext()));
24882489
}

0 commit comments

Comments
 (0)