summaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMats Jun Larsen <mats@jun.codes>2025-01-21 00:32:56 +0900
committerGitHub <noreply@github.com>2025-01-21 00:32:56 +0900
commit416f1c465db62d829283f6902ef35e027e127aa7 (patch)
tree876ba62997d586d463159f4cfe977d4c0cea5b05 /llvm/lib/Transforms
parent9c7e02d579db7ba81a414cd2212ce2b48b927941 (diff)
[IR] Replace of PointerType::get(Type) with opaque version (NFC) (#123617)
In accordance with https://github.com/llvm/llvm-project/issues/123569 In order to keep the patch at reasonable size, this PR only covers for the llvm subproject, unittests excluded.
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/CFGuard/CFGuard.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/AttributorAttributes.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp5
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp14
-rw-r--r--llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemProfiler.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp4
-rw-r--r--llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/CodeExtractor.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/ModuleUtils.cpp8
11 files changed, 23 insertions, 24 deletions
diff --git a/llvm/lib/Transforms/CFGuard/CFGuard.cpp b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
index 0e1a0a6ed947..41d68b62eb8d 100644
--- a/llvm/lib/Transforms/CFGuard/CFGuard.cpp
+++ b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
@@ -247,7 +247,7 @@ bool CFGuardImpl::doInitialization(Module &M) {
GuardFnType =
FunctionType::get(Type::getVoidTy(M.getContext()),
{PointerType::getUnqual(M.getContext())}, false);
- GuardFnPtrType = PointerType::get(GuardFnType, 0);
+ GuardFnPtrType = PointerType::get(M.getContext(), 0);
GuardFnGlobal = M.getOrInsertGlobal(GuardFnName, GuardFnPtrType, [&] {
auto *Var = new GlobalVariable(M, GuardFnPtrType, false,
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 46d6d66593b4..e897632489bb 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -12344,7 +12344,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
ChangeStatus Changed = ChangeStatus::UNCHANGED;
Value *FP = CB->getCalledOperand();
if (FP->getType()->getPointerAddressSpace())
- FP = new AddrSpaceCastInst(FP, PointerType::get(FP->getType(), 0),
+ FP = new AddrSpaceCastInst(FP, PointerType::get(FP->getContext(), 0),
FP->getName() + ".as0", CB->getIterator());
bool CBIsVoid = CB->getType()->isVoidTy();
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index cb8458831849..cca6f78084b4 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1035,7 +1035,8 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
RuntimeCallInserter &RTCI)
: F(F), ASan(ASan), RTCI(RTCI),
DIB(*F.getParent(), /*AllowUnresolved*/ false), C(ASan.C),
- IntptrTy(ASan.IntptrTy), IntptrPtrTy(PointerType::get(IntptrTy, 0)),
+ IntptrTy(ASan.IntptrTy),
+ IntptrPtrTy(PointerType::get(IntptrTy->getContext(), 0)),
Mapping(ASan.Mapping),
PoisonStack(ClStack &&
!Triple(F.getParent()->getTargetTriple()).isAMDGPU()) {}
@@ -1882,7 +1883,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
Type *ShadowTy =
IntegerType::get(*C, std::max(8U, TypeStoreSize >> Mapping.Scale));
- Type *ShadowPtrTy = PointerType::get(ShadowTy, 0);
+ Type *ShadowPtrTy = PointerType::get(*C, 0);
Value *ShadowPtr = memToShadow(AddrLong, IRB);
const uint64_t ShadowAlign =
std::max<uint64_t>(Alignment.valueOrOne().value() >> Mapping.Scale, 1);
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index e226727e64d3..6ba280d46012 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1790,13 +1790,12 @@ Value *DFSanFunction::getArgTLS(Type *T, unsigned ArgOffset, IRBuilder<> &IRB) {
Value *Base = IRB.CreatePointerCast(DFS.ArgTLS, DFS.IntptrTy);
if (ArgOffset)
Base = IRB.CreateAdd(Base, ConstantInt::get(DFS.IntptrTy, ArgOffset));
- return IRB.CreateIntToPtr(Base, PointerType::get(DFS.getShadowTy(T), 0),
- "_dfsarg");
+ return IRB.CreateIntToPtr(Base, PointerType::get(*DFS.Ctx, 0), "_dfsarg");
}
Value *DFSanFunction::getRetvalTLS(Type *T, IRBuilder<> &IRB) {
- return IRB.CreatePointerCast(
- DFS.RetvalTLS, PointerType::get(DFS.getShadowTy(T), 0), "_dfsret");
+ return IRB.CreatePointerCast(DFS.RetvalTLS, PointerType::get(*DFS.Ctx, 0),
+ "_dfsret");
}
Value *DFSanFunction::getRetvalOriginTLS() { return DFS.RetvalOriginTLS; }
@@ -1926,8 +1925,7 @@ DataFlowSanitizer::getShadowOriginAddress(Value *Addr, Align InstAlignment,
IRB.CreateAdd(ShadowLong, ConstantInt::get(IntptrTy, ShadowBase));
}
IntegerType *ShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
- Value *ShadowPtr =
- IRB.CreateIntToPtr(ShadowLong, PointerType::get(ShadowTy, 0));
+ Value *ShadowPtr = IRB.CreateIntToPtr(ShadowLong, PointerType::get(*Ctx, 0));
Value *OriginPtr = nullptr;
if (shouldTrackOrigins()) {
Value *OriginLong = ShadowOffset;
@@ -2491,8 +2489,8 @@ void DFSanFunction::paintOrigin(IRBuilder<> &IRB, Value *Origin,
Align CurrentAlignment = Alignment;
if (Alignment >= IntptrAlignment && IntptrSize > OriginSize) {
Value *IntptrOrigin = originToIntptr(IRB, Origin);
- Value *IntptrStoreOriginPtr = IRB.CreatePointerCast(
- StoreOriginAddr, PointerType::get(DFS.IntptrTy, 0));
+ Value *IntptrStoreOriginPtr =
+ IRB.CreatePointerCast(StoreOriginAddr, PointerType::get(*DFS.Ctx, 0));
for (unsigned I = 0; I < StoreOriginSize / IntptrSize; ++I) {
Value *Ptr =
I ? IRB.CreateConstGEP1_32(DFS.IntptrTy, IntptrStoreOriginPtr, I)
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 6e86ffdc8027..5e204d736237 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -1012,7 +1012,7 @@ void GCOVProfiler::emitGlobalConstructor(
IRBuilder<> Builder(BB);
FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
- auto *PFTy = PointerType::get(FTy, 0);
+ auto *PFTy = PointerType::get(*Ctx, 0);
FTy = FunctionType::get(Builder.getVoidTy(), {PFTy, PFTy}, false);
// Initialize the environment and register the local writeout, flush and
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index f1580b025efc..9a7eec76cc1d 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -511,7 +511,7 @@ void MemProfiler::instrumentAddress(Instruction *OrigIns,
}
Type *ShadowTy = ClHistogram ? Type::getInt8Ty(*C) : Type::getInt64Ty(*C);
- Type *ShadowPtrTy = PointerType::get(ShadowTy, 0);
+ Type *ShadowPtrTy = PointerType::get(*C, 0);
Value *ShadowPtr = memToShadow(AddrLong, IRB);
Value *ShadowAddr = IRB.CreateIntToPtr(ShadowPtr, ShadowPtrTy);
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 6daee7a3b6e8..587e5c1cc842 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -6188,7 +6188,7 @@ struct VarArgI386Helper : public VarArgHelperBase {
Type *RegSaveAreaPtrTy = PointerType::getUnqual(*MS.C);
Value *RegSaveAreaPtrPtr =
IRB.CreateIntToPtr(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
- PointerType::get(RegSaveAreaPtrTy, 0));
+ PointerType::get(*MS.C, 0));
Value *RegSaveAreaPtr =
IRB.CreateLoad(RegSaveAreaPtrTy, RegSaveAreaPtrPtr);
Value *RegSaveAreaShadowPtr, *RegSaveAreaOriginPtr;
@@ -6273,7 +6273,7 @@ struct VarArgGenericHelper : public VarArgHelperBase {
Type *RegSaveAreaPtrTy = PointerType::getUnqual(*MS.C);
Value *RegSaveAreaPtrPtr =
IRB.CreateIntToPtr(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
- PointerType::get(RegSaveAreaPtrTy, 0));
+ PointerType::get(*MS.C, 0));
Value *RegSaveAreaPtr =
IRB.CreateLoad(RegSaveAreaPtrTy, RegSaveAreaPtrPtr);
Value *RegSaveAreaShadowPtr, *RegSaveAreaOriginPtr;
diff --git a/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
index 2ae810621866..94101f9663a8 100644
--- a/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
@@ -598,7 +598,7 @@ bool TypeSanitizer::instrumentWithShadowUpdate(
Value *ShadowDataInt = convertToShadowDataInt(IRB, Ptr, IntptrTy, PtrShift,
ShadowBase, AppMemMask);
- Type *Int8PtrPtrTy = PointerType::get(IRB.getPtrTy(), 0);
+ Type *Int8PtrPtrTy = PointerType::get(IRB.getContext(), 0);
Value *ShadowData =
IRB.CreateIntToPtr(ShadowDataInt, Int8PtrPtrTy, "shadow.ptr");
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index af9813775f24..ecc91739a796 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -849,7 +849,7 @@ Function *CodeExtractor::constructFunctionDeclaration(
StructValues.insert(output);
} else
ParamTy.push_back(
- PointerType::get(output->getType(), DL.getAllocaAddrSpace()));
+ PointerType::get(output->getContext(), DL.getAllocaAddrSpace()));
}
assert(
@@ -863,7 +863,7 @@ Function *CodeExtractor::constructFunctionDeclaration(
if (!AggParamTy.empty()) {
StructTy = StructType::get(M->getContext(), AggParamTy);
ParamTy.push_back(PointerType::get(
- StructTy, ArgsInZeroAddressSpace ? 0 : DL.getAllocaAddrSpace()));
+ M->getContext(), ArgsInZeroAddressSpace ? 0 : DL.getAllocaAddrSpace()));
}
Type *RetTy = getSwitchType();
diff --git a/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp b/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
index cd7960065703..ff72ba073ad0 100644
--- a/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
+++ b/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
@@ -138,7 +138,7 @@ static bool runImpl(Module &M) {
FunctionCallee AtExit = M.getOrInsertFunction(
"__cxa_atexit",
FunctionType::get(Type::getInt32Ty(C),
- {PointerType::get(AtExitFuncTy, 0), VoidStar, VoidStar},
+ {PointerType::get(C, 0), VoidStar, VoidStar},
/*isVarArg=*/false));
// If __cxa_atexit is defined (e.g. in the case of LTO) and arg0 is not
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 7249571f3449..df31a3d5d7c5 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -45,9 +45,9 @@ static void appendToGlobalArray(StringRef ArrayName, Module &M, Function *F,
}
GVCtor->eraseFromParent();
} else {
- EltTy = StructType::get(IRB.getInt32Ty(),
- PointerType::get(FnTy, F->getAddressSpace()),
- IRB.getPtrTy());
+ EltTy = StructType::get(
+ IRB.getInt32Ty(),
+ PointerType::get(M.getContext(), F->getAddressSpace()), IRB.getPtrTy());
}
// Build a 3 field global_ctor entry. We don't take a comdat key.
@@ -268,7 +268,7 @@ std::pair<Function *, FunctionCallee> llvm::createSanitizerCtorAndInitFunctions(
BasicBlock::Create(M.getContext(), "callfunc", Ctor, RetBB);
auto *InitFn = cast<Function>(InitFunction.getCallee());
auto *InitFnPtr =
- PointerType::get(InitFn->getType(), InitFn->getAddressSpace());
+ PointerType::get(M.getContext(), InitFn->getAddressSpace());
IRB.SetInsertPoint(EntryBB);
Value *InitNotNull =
IRB.CreateICmpNE(InitFn, ConstantPointerNull::get(InitFnPtr));