[llvm] [polly] [clang] [NFC] Remove Type::getInt8PtrTy (PR #71029)
Paulo Matos via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 6 23:52:35 PST 2023
https://github.com/pmatos updated https://github.com/llvm/llvm-project/pull/71029
>From fe3ed6bcc6eface6e7bfa3e9b043f8287dd129b0 Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at linki.tools>
Date: Fri, 3 Nov 2023 12:03:07 +0100
Subject: [PATCH 1/3] [NFC] Remove Type::getInt8PtrTy
Replace this with PointerType::getUnqual().
Followup to the opaque pointer transition. Fixes an in-code TODO item.
---
clang/lib/CodeGen/CGGPUBuiltin.cpp | 13 +--
clang/lib/CodeGen/CodeGenTypes.cpp | 2 +-
clang/lib/CodeGen/CoverageMappingGen.cpp | 2 +-
.../clang-linker-wrapper/OffloadWrapper.cpp | 53 ++++++------
llvm/examples/BrainF/BrainF.cpp | 2 +-
llvm/include/llvm/IR/Type.h | 5 --
.../llvm/ProfileData/InstrProfData.inc | 12 +--
llvm/lib/Analysis/StackSafetyAnalysis.cpp | 4 +-
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +-
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +-
llvm/lib/CodeGen/DwarfEHPrepare.cpp | 8 +-
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 8 +-
llvm/lib/CodeGen/SafeStack.cpp | 2 +-
llvm/lib/CodeGen/ShadowStackGCLowering.cpp | 2 +-
llvm/lib/CodeGen/SjLjEHPrepare.cpp | 2 +-
llvm/lib/CodeGen/StackProtector.cpp | 4 +-
llvm/lib/CodeGen/TargetLoweringBase.cpp | 12 +--
llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 2 +-
llvm/lib/Frontend/Offloading/Utility.cpp | 10 +--
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 85 ++++++++++++++-----
llvm/lib/IR/Type.cpp | 4 -
.../Target/AArch64/AArch64ISelLowering.cpp | 9 +-
.../AMDGPU/AMDGPULowerModuleLDSPass.cpp | 2 +-
.../AMDGPUOpenCLEnqueuedBlockLowering.cpp | 6 +-
llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 +-
.../Target/BPF/BPFAbstractMemberAccess.cpp | 3 +-
llvm/lib/Target/DirectX/DXILOpBuilder.cpp | 3 +-
llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 2 +-
llvm/lib/Target/X86/X86ISelLowering.cpp | 4 +-
llvm/lib/Target/X86/X86ISelLoweringCall.cpp | 4 +-
llvm/lib/Target/X86/X86WinEHState.cpp | 22 ++---
llvm/lib/Target/XCore/XCoreISelLowering.cpp | 2 +-
llvm/lib/Transforms/CFGuard/CFGuard.cpp | 5 +-
llvm/lib/Transforms/Coroutines/CoroElide.cpp | 2 +-
llvm/lib/Transforms/Coroutines/CoroInstr.h | 6 +-
llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 8 +-
.../Instrumentation/AddressSanitizer.cpp | 4 +-
.../Instrumentation/DataFlowSanitizer.cpp | 8 +-
.../Instrumentation/GCOVProfiling.cpp | 6 +-
.../Instrumentation/InstrProfiling.cpp | 10 +--
.../Instrumentation/PGOInstrumentation.cpp | 2 +-
.../Transforms/Scalar/LoopDataPrefetch.cpp | 2 +-
.../Scalar/RewriteStatepointsForGC.cpp | 2 +-
.../Scalar/StraightLineStrengthReduce.cpp | 2 +-
llvm/lib/Transforms/Utils/CodeExtractor.cpp | 2 +-
.../Utils/EntryExitInstrumenter.cpp | 6 +-
.../lib/Transforms/Utils/EscapeEnumerator.cpp | 2 +-
llvm/lib/Transforms/Utils/InlineFunction.cpp | 4 +-
.../lib/Transforms/Utils/LowerGlobalDtors.cpp | 2 +-
llvm/lib/Transforms/Utils/ModuleUtils.cpp | 2 +-
llvm/lib/Transforms/Utils/SanitizerStats.cpp | 11 +--
llvm/tools/bugpoint/Miscompilation.cpp | 4 +-
.../Analysis/CGSCCPassManagerTest.cpp | 27 +++---
llvm/unittests/Analysis/LazyCallGraphTest.cpp | 60 +++++++------
.../unittests/Analysis/MemoryBuiltinsTest.cpp | 2 +-
.../Analysis/ScalarEvolutionTest.cpp | 2 +-
.../Frontend/OpenMPIRBuilderTest.cpp | 4 +-
llvm/unittests/FuzzMutate/OperationsTest.cpp | 4 +-
llvm/unittests/Linker/LinkModulesTest.cpp | 18 ++--
polly/lib/Analysis/ScopDetection.cpp | 2 +-
60 files changed, 281 insertions(+), 225 deletions(-)
diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index 75fb06de938425d..de4ee68c0da1e79 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -23,8 +23,8 @@ using namespace CodeGen;
namespace {
llvm::Function *GetVprintfDeclaration(llvm::Module &M) {
- llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()),
- llvm::Type::getInt8PtrTy(M.getContext())};
+ llvm::Type *ArgTypes[] = {llvm::PointerType::getUnqual(M.getContext()),
+ llvm::PointerType::getUnqual(M.getContext())};
llvm::FunctionType *VprintfFuncType = llvm::FunctionType::get(
llvm::Type::getInt32Ty(M.getContext()), ArgTypes, false);
@@ -45,8 +45,8 @@ llvm::Function *GetVprintfDeclaration(llvm::Module &M) {
llvm::Function *GetOpenMPVprintfDeclaration(CodeGenModule &CGM) {
const char *Name = "__llvm_omp_vprintf";
llvm::Module &M = CGM.getModule();
- llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()),
- llvm::Type::getInt8PtrTy(M.getContext()),
+ llvm::Type *ArgTypes[] = {llvm::PointerType::getUnqual(M.getContext()),
+ llvm::PointerType::getUnqual(M.getContext()),
llvm::Type::getInt32Ty(M.getContext())};
llvm::FunctionType *VprintfFuncType = llvm::FunctionType::get(
llvm::Type::getInt32Ty(M.getContext()), ArgTypes, false);
@@ -99,7 +99,8 @@ packArgsIntoNVPTXFormatBuffer(CodeGenFunction *CGF, const CallArgList &Args) {
// Construct and fill the args buffer that we'll pass to vprintf.
if (Args.size() <= 1) {
// If there are no args, pass a null pointer and size 0
- llvm::Value * BufferPtr = llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
+ llvm::Value *BufferPtr =
+ llvm::ConstantPointerNull::get(llvm::PointerType::getUnqual(Ctx));
return {BufferPtr, llvm::TypeSize::Fixed(0)};
} else {
llvm::SmallVector<llvm::Type *, 8> ArgTypes;
@@ -120,7 +121,7 @@ packArgsIntoNVPTXFormatBuffer(CodeGenFunction *CGF, const CallArgList &Args) {
Builder.CreateAlignedStore(Arg, P, DL.getPrefTypeAlign(Arg->getType()));
}
llvm::Value *BufferPtr =
- Builder.CreatePointerCast(Alloca, llvm::Type::getInt8PtrTy(Ctx));
+ Builder.CreatePointerCast(Alloca, llvm::PointerType::getUnqual(Ctx));
return {BufferPtr, DL.getTypeAllocSize(AllocaTy)};
}
}
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 29f4f51dc08b5ec..a6b51bfef87652d 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -422,7 +422,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::NullPtr:
// Model std::nullptr_t as i8*
- ResultType = llvm::Type::getInt8PtrTy(getLLVMContext());
+ ResultType = llvm::PointerType::getUnqual(getLLVMContext());
break;
case BuiltinType::UInt128:
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index d77aa4dd78a06b3..b16358ee117ae20 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1820,7 +1820,7 @@ void CoverageMappingModuleGen::emit() {
CGM.addUsedGlobal(CovData);
// Create the deferred function records array
if (!FunctionNames.empty()) {
- auto NamesArrTy = llvm::ArrayType::get(llvm::Type::getInt8PtrTy(Ctx),
+ auto NamesArrTy = llvm::ArrayType::get(llvm::PointerType::getUnqual(Ctx),
FunctionNames.size());
auto NamesArrVal = llvm::ConstantArray::get(NamesArrTy, FunctionNames);
// This variable will *NOT* be emitted to the object file. It is used
diff --git a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
index e562c20432e37c6..64f704498c0b7ca 100644
--- a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -40,7 +40,7 @@ enum OffloadEntryKindFlag : uint32_t {
IntegerType *getSizeTTy(Module &M) {
LLVMContext &C = M.getContext();
- switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
+ switch (M.getDataLayout().getPointerTypeSize(PointerType::getUnqual(C))) {
case 4u:
return Type::getInt32Ty(C);
case 8u:
@@ -60,9 +60,10 @@ StructType *getEntryTy(Module &M) {
LLVMContext &C = M.getContext();
StructType *EntryTy = StructType::getTypeByName(C, "__tgt_offload_entry");
if (!EntryTy)
- EntryTy = StructType::create("__tgt_offload_entry", Type::getInt8PtrTy(C),
- Type::getInt8PtrTy(C), getSizeTTy(M),
- Type::getInt32Ty(C), Type::getInt32Ty(C));
+ EntryTy =
+ StructType::create("__tgt_offload_entry", PointerType::getUnqual(C),
+ PointerType::getUnqual(C), getSizeTTy(M),
+ Type::getInt32Ty(C), Type::getInt32Ty(C));
return EntryTy;
}
@@ -80,9 +81,9 @@ StructType *getDeviceImageTy(Module &M) {
LLVMContext &C = M.getContext();
StructType *ImageTy = StructType::getTypeByName(C, "__tgt_device_image");
if (!ImageTy)
- ImageTy = StructType::create("__tgt_device_image", Type::getInt8PtrTy(C),
- Type::getInt8PtrTy(C), getEntryPtrTy(M),
- getEntryPtrTy(M));
+ ImageTy = StructType::create(
+ "__tgt_device_image", PointerType::getUnqual(C),
+ PointerType::getUnqual(C), getEntryPtrTy(M), getEntryPtrTy(M));
return ImageTy;
}
@@ -284,9 +285,9 @@ StructType *getFatbinWrapperTy(Module &M) {
LLVMContext &C = M.getContext();
StructType *FatbinTy = StructType::getTypeByName(C, "fatbin_wrapper");
if (!FatbinTy)
- FatbinTy = StructType::create("fatbin_wrapper", Type::getInt32Ty(C),
- Type::getInt32Ty(C), Type::getInt8PtrTy(C),
- Type::getInt8PtrTy(C));
+ FatbinTy = StructType::create(
+ "fatbin_wrapper", Type::getInt32Ty(C), Type::getInt32Ty(C),
+ PointerType::getUnqual(C), PointerType::getUnqual(C));
return FatbinTy;
}
@@ -294,7 +295,7 @@ StructType *getFatbinWrapperTy(Module &M) {
/// runtime.
GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP) {
LLVMContext &C = M.getContext();
- llvm::Type *Int8PtrTy = Type::getInt8PtrTy(C);
+ llvm::Type *Int8PtrTy = PointerType::getUnqual(C);
llvm::Triple Triple = llvm::Triple(M.getTargetTriple());
// Create the global string containing the fatbinary.
@@ -315,7 +316,7 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP) {
ConstantInt::get(Type::getInt32Ty(C), IsHIP ? HIPFatMagic : CudaFatMagic),
ConstantInt::get(Type::getInt32Ty(C), 1),
ConstantExpr::getPointerBitCastOrAddrSpaceCast(Fatbin, Int8PtrTy),
- ConstantPointerNull::get(Type::getInt8PtrTy(C))};
+ ConstantPointerNull::get(PointerType::getUnqual(C))};
Constant *FatbinInitializer =
ConstantStruct::get(getFatbinWrapperTy(M), FatbinWrapper);
@@ -529,21 +530,21 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
DtorFunc->setSection(".text.startup");
// Get the __cudaRegisterFatBinary function declaration.
- auto *RegFatTy = FunctionType::get(Type::getInt8PtrTy(C)->getPointerTo(),
- Type::getInt8PtrTy(C),
+ auto *RegFatTy = FunctionType::get(PointerType::getUnqual(C)->getPointerTo(),
+ PointerType::getUnqual(C),
/*isVarArg*/ false);
FunctionCallee RegFatbin = M.getOrInsertFunction(
IsHIP ? "__hipRegisterFatBinary" : "__cudaRegisterFatBinary", RegFatTy);
// Get the __cudaRegisterFatBinaryEnd function declaration.
- auto *RegFatEndTy = FunctionType::get(Type::getVoidTy(C),
- Type::getInt8PtrTy(C)->getPointerTo(),
- /*isVarArg*/ false);
+ auto *RegFatEndTy = FunctionType::get(
+ Type::getVoidTy(C), PointerType::getUnqual(C)->getPointerTo(),
+ /*isVarArg*/ false);
FunctionCallee RegFatbinEnd =
M.getOrInsertFunction("__cudaRegisterFatBinaryEnd", RegFatEndTy);
// Get the __cudaUnregisterFatBinary function declaration.
- auto *UnregFatTy = FunctionType::get(Type::getVoidTy(C),
- Type::getInt8PtrTy(C)->getPointerTo(),
- /*isVarArg*/ false);
+ auto *UnregFatTy = FunctionType::get(
+ Type::getVoidTy(C), PointerType::getUnqual(C)->getPointerTo(),
+ /*isVarArg*/ false);
FunctionCallee UnregFatbin = M.getOrInsertFunction(
IsHIP ? "__hipUnregisterFatBinary" : "__cudaUnregisterFatBinary",
UnregFatTy);
@@ -554,19 +555,19 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy);
auto *BinaryHandleGlobal = new llvm::GlobalVariable(
- M, Type::getInt8PtrTy(C)->getPointerTo(), false,
+ M, PointerType::getUnqual(C)->getPointerTo(), false,
llvm::GlobalValue::InternalLinkage,
- llvm::ConstantPointerNull::get(Type::getInt8PtrTy(C)->getPointerTo()),
+ llvm::ConstantPointerNull::get(PointerType::getUnqual(C)->getPointerTo()),
IsHIP ? ".hip.binary_handle" : ".cuda.binary_handle");
// Create the constructor to register this image with the runtime.
IRBuilder<> CtorBuilder(BasicBlock::Create(C, "entry", CtorFunc));
CallInst *Handle = CtorBuilder.CreateCall(
RegFatbin, ConstantExpr::getPointerBitCastOrAddrSpaceCast(
- FatbinDesc, Type::getInt8PtrTy(C)));
+ FatbinDesc, PointerType::getUnqual(C)));
CtorBuilder.CreateAlignedStore(
Handle, BinaryHandleGlobal,
- Align(M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))));
+ Align(M.getDataLayout().getPointerTypeSize(PointerType::getUnqual(C))));
CtorBuilder.CreateCall(createRegisterGlobalsFunction(M, IsHIP), Handle);
if (!IsHIP)
CtorBuilder.CreateCall(RegFatbinEnd, Handle);
@@ -578,8 +579,8 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
// `atexit()` intead.
IRBuilder<> DtorBuilder(BasicBlock::Create(C, "entry", DtorFunc));
LoadInst *BinaryHandle = DtorBuilder.CreateAlignedLoad(
- Type::getInt8PtrTy(C)->getPointerTo(), BinaryHandleGlobal,
- Align(M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))));
+ PointerType::getUnqual(C)->getPointerTo(), BinaryHandleGlobal,
+ Align(M.getDataLayout().getPointerTypeSize(PointerType::getUnqual(C))));
DtorBuilder.CreateCall(UnregFatbin, BinaryHandle);
DtorBuilder.CreateRetVoid();
diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index 849e5c7675307ec..53db48be04ac917 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/examples/BrainF/BrainF.cpp
@@ -67,7 +67,7 @@ void BrainF::header(LLVMContext& C) {
//Function prototypes
//declare void @llvm.memset.p0i8.i32(i8 *, i8, i32, i1)
- Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) };
+ Type *Tys[] = {PointerType::getUnqual(C), Type::getInt32Ty(C)};
Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset,
Tys);
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index c38078cc6087ef7..1f0133c08e7d607 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -482,11 +482,6 @@ class Type {
//===--------------------------------------------------------------------===//
// Convenience methods for getting pointer types.
//
-
- // TODO: After opaque pointer transition this can be replaced by simply
- // calling PointerType::get(C, AS).
- static PointerType *getInt8PtrTy(LLVMContext &C, unsigned AS = 0);
-
static Type *getWasm_ExternrefTy(LLVMContext &C);
static Type *getWasm_FuncrefTy(LLVMContext &C);
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index fa17ac370f6964f..44a449800923fdc 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -81,9 +81,9 @@ INSTR_PROF_DATA(const IntPtrT, IntPtrTy, BitmapPtr, RelativeBitmapPtr)
* function name hashes during the conversion from raw to merged profile
* data.
*/
-INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \
+INSTR_PROF_DATA(const IntPtrT, llvm::PointerType::getUnqual(Ctx), FunctionPointer, \
FunctionAddr)
-INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
+INSTR_PROF_DATA(IntPtrT, llvm::PointerType::getUnqual(Ctx), Values, \
ValuesPtrExpr)
INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
@@ -116,7 +116,7 @@ INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Value, \
ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0))
INSTR_PROF_VALUE_NODE(uint64_t, llvm::Type::getInt64Ty(Ctx), Count, \
ConstantInt::get(llvm::Type::GetInt64Ty(Ctx), 0))
-INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
+INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::PointerType::getUnqual(Ctx), Next, \
ConstantInt::get(llvm::Type::GetInt8PtrTy(Ctx), 0))
#undef INSTR_PROF_VALUE_NODE
/* INSTR_PROF_VALUE_NODE end. */
@@ -160,7 +160,7 @@ INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
#endif
VALUE_PROF_FUNC_PARAM(uint64_t, TargetValue, Type::getInt64Ty(Ctx)) \
INSTR_PROF_COMMA
-VALUE_PROF_FUNC_PARAM(void *, Data, Type::getInt8PtrTy(Ctx)) INSTR_PROF_COMMA
+VALUE_PROF_FUNC_PARAM(void *, Data, PointerType::getUnqual(Ctx)) INSTR_PROF_COMMA
VALUE_PROF_FUNC_PARAM(uint32_t, CounterIndex, Type::getInt32Ty(Ctx))
#undef VALUE_PROF_FUNC_PARAM
#undef INSTR_PROF_COMMA
@@ -213,9 +213,9 @@ VALUE_PROF_KIND(IPVK_Last, IPVK_MemOPSize, "last")
#define INSTR_PROF_DATA_DEFINED
#endif
#ifdef COVMAP_V1
-COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
+COVMAP_FUNC_RECORD(const IntPtrT, llvm::PointerType::getUnqual(Ctx), \
NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
- llvm::Type::getInt8PtrTy(Ctx)))
+ llvm::PointerType::getUnqual(Ctx)))
COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
NameValue.size()))
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index d7cfec7b19b17b0..da21e3f28e78993 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -272,7 +272,7 @@ ConstantRange StackSafetyLocalAnalysis::offsetFrom(Value *Addr, Value *Base) {
if (!SE.isSCEVable(Addr->getType()) || !SE.isSCEVable(Base->getType()))
return UnknownRange;
- auto *PtrTy = IntegerType::getInt8PtrTy(SE.getContext());
+ auto *PtrTy = PointerType::getUnqual(SE.getContext());
const SCEV *AddrExp = SE.getTruncateOrZeroExtend(SE.getSCEV(Addr), PtrTy);
const SCEV *BaseExp = SE.getTruncateOrZeroExtend(SE.getSCEV(Base), PtrTy);
const SCEV *Diff = SE.getMinusSCEV(AddrExp, BaseExp);
@@ -363,7 +363,7 @@ bool StackSafetyLocalAnalysis::isSafeAccess(const Use &U, AllocaInst *AI,
const auto *I = cast<Instruction>(U.getUser());
auto ToCharPtr = [&](const SCEV *V) {
- auto *PtrTy = IntegerType::getInt8PtrTy(SE.getContext());
+ auto *PtrTy = PointerType::getUnqual(SE.getContext());
return SE.getTruncateOrZeroExtend(V, PtrTy);
};
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 5e3341d4de13323..3a17ee1f9482f23 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -5178,7 +5178,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
// Save llvm.compiler.used and remove it.
SmallVector<Constant *, 2> UsedArray;
SmallVector<GlobalValue *, 4> UsedGlobals;
- Type *UsedElementType = Type::getInt8PtrTy(M.getContext());
+ Type *UsedElementType = PointerType::getUnqual(M.getContext());
GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true);
for (auto *GV : UsedGlobals) {
if (GV->getName() != "llvm.embedded.module" &&
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index eb189dc1569c203..71bee8cce65126b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2322,7 +2322,7 @@ bool AsmPrinter::doFinalization(Module &M) {
auto SymbolName = "swift_async_extendedFramePointerFlags";
auto Global = M.getGlobalVariable(SymbolName);
if (!Global) {
- auto Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+ auto Int8PtrTy = PointerType::getUnqual(M.getContext());
Global = new GlobalVariable(M, Int8PtrTy, false,
GlobalValue::ExternalWeakLinkage, nullptr,
SymbolName);
diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp
index 1d02f53e51e566e..50cb010bbfc36d0 100644
--- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp
@@ -227,8 +227,8 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
DoesRewindFunctionNeedExceptionObject = false;
} else {
RewindName = TLI.getLibcallName(RTLIB::UNWIND_RESUME);
- FTy =
- FunctionType::get(Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx), false);
+ FTy = FunctionType::get(Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx),
+ false);
RewindFunctionCallingConv = TLI.getLibcallCallingConv(RTLIB::UNWIND_RESUME);
DoesRewindFunctionNeedExceptionObject = true;
}
@@ -269,8 +269,8 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
llvm::SmallVector<Value *, 1> RewindFunctionArgs;
BasicBlock *UnwindBB = BasicBlock::Create(Ctx, "unwind_resume", &F);
- PHINode *PN = PHINode::Create(Type::getInt8PtrTy(Ctx), ResumesLeft, "exn.obj",
- UnwindBB);
+ PHINode *PN = PHINode::Create(PointerType::getUnqual(Ctx), ResumesLeft,
+ "exn.obj", UnwindBB);
// Extract the exception object from the ResumeInst and add it to the PHI node
// that feeds the _Unwind_Resume call.
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 561405d743b16f5..178f1fc9313d71b 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -768,7 +768,7 @@ void IRTranslator::emitJumpTable(SwitchCG::JumpTable &JT,
MIB.setMBB(*MBB);
MIB.setDebugLoc(CurBuilder->getDebugLoc());
- Type *PtrIRTy = Type::getInt8PtrTy(MF->getFunction().getContext());
+ Type *PtrIRTy = PointerType::getUnqual(MF->getFunction().getContext());
const LLT PtrTy = getLLTForType(*PtrIRTy, *DL);
auto Table = MIB.buildJumpTable(PtrTy, JT.JTI);
@@ -1016,7 +1016,7 @@ void IRTranslator::emitBitTestHeader(SwitchCG::BitTestBlock &B,
Register MinValReg = MIB.buildConstant(SwitchOpTy, B.First).getReg(0);
auto RangeSub = MIB.buildSub(SwitchOpTy, SwitchOpReg, MinValReg);
- Type *PtrIRTy = Type::getInt8PtrTy(MF->getFunction().getContext());
+ Type *PtrIRTy = PointerType::getUnqual(MF->getFunction().getContext());
const LLT PtrTy = getLLTForType(*PtrIRTy, *DL);
LLT MaskTy = SwitchOpTy;
@@ -3347,7 +3347,7 @@ bool IRTranslator::emitSPDescriptorParent(StackProtectorDescriptor &SPD,
CurBuilder->setInsertPt(*ParentBB, ParentBB->end());
// First create the loads to the guard/stack slot for the comparison.
const TargetLowering &TLI = *MF->getSubtarget().getTargetLowering();
- Type *PtrIRTy = Type::getInt8PtrTy(MF->getFunction().getContext());
+ Type *PtrIRTy = PointerType::getUnqual(MF->getFunction().getContext());
const LLT PtrTy = getLLTForType(*PtrIRTy, *DL);
LLT PtrMemTy = getLLTForMVT(TLI.getPointerMemTy(*DL));
@@ -3357,7 +3357,7 @@ bool IRTranslator::emitSPDescriptorParent(StackProtectorDescriptor &SPD,
Register Guard;
Register StackSlotPtr = CurBuilder->buildFrameIndex(PtrTy, FI).getReg(0);
const Module &M = *ParentBB->getParent()->getFunction().getParent();
- Align Align = DL->getPrefTypeAlign(Type::getInt8PtrTy(M.getContext()));
+ Align Align = DL->getPrefTypeAlign(PointerType::getUnqual(M.getContext()));
// Generate code to load the content of the guard slot.
Register GuardVal =
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp
index bcad7a3f24dabe8..368e6933f83b31c 100644
--- a/llvm/lib/CodeGen/SafeStack.cpp
+++ b/llvm/lib/CodeGen/SafeStack.cpp
@@ -192,7 +192,7 @@ class SafeStack {
SafeStack(Function &F, const TargetLoweringBase &TL, const DataLayout &DL,
DomTreeUpdater *DTU, ScalarEvolution &SE)
: F(F), TL(TL), DL(DL), DTU(DTU), SE(SE),
- StackPtrTy(Type::getInt8PtrTy(F.getContext())),
+ StackPtrTy(PointerType::getUnqual(F.getContext())),
IntPtrTy(DL.getIntPtrType(F.getContext())),
Int32Ty(Type::getInt32Ty(F.getContext())),
Int8Ty(Type::getInt8Ty(F.getContext())) {}
diff --git a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
index 153fe77b8b4ae4a..246e9a5271cb0dc 100644
--- a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
+++ b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp
@@ -106,7 +106,7 @@ ShadowStackGCLowering::ShadowStackGCLowering() : FunctionPass(ID) {
Constant *ShadowStackGCLowering::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value.
- Type *VoidPtr = Type::getInt8PtrTy(F.getContext());
+ Type *VoidPtr = PointerType::getUnqual(F.getContext());
// Truncate the ShadowStackDescriptor if some metadata is null.
unsigned NumMeta = 0;
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
index 7994821ae7c0a14..1df1a464a54b0d0 100644
--- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
@@ -90,7 +90,7 @@ FunctionPass *llvm::createSjLjEHPreparePass(const TargetMachine *TM) {
bool SjLjEHPrepare::doInitialization(Module &M) {
// Build the function context structure.
// builtin_setjmp uses a five word jbuf
- Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
+ Type *VoidPtrTy = PointerType::getUnqual(M.getContext());
unsigned DataBits =
TM ? TM->getSjLjDataSize() : TargetMachine::DefaultSjLjDataSize;
DataTy = Type::getIntNTy(M.getContext(), DataBits);
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index 3ba85bc125a0190..71676843eaf907d 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -451,7 +451,7 @@ static bool CreatePrologue(Function *F, Module *M, Instruction *CheckLoc,
const TargetLoweringBase *TLI, AllocaInst *&AI) {
bool SupportsSelectionDAGSP = false;
IRBuilder<> B(&F->getEntryBlock().front());
- PointerType *PtrTy = Type::getInt8PtrTy(CheckLoc->getContext());
+ PointerType *PtrTy = PointerType::getUnqual(CheckLoc->getContext());
AI = B.CreateAlloca(PtrTy, nullptr, "StackGuardSlot");
Value *GuardSlot = getStackGuard(TLI, M, B, &SupportsSelectionDAGSP);
@@ -622,7 +622,7 @@ BasicBlock *StackProtector::CreateFailBB() {
if (Trip.isOSOpenBSD()) {
StackChkFail = M->getOrInsertFunction("__stack_smash_handler",
Type::getVoidTy(Context),
- Type::getInt8PtrTy(Context));
+ PointerType::getUnqual(Context));
Args.push_back(B.CreateGlobalStringPtr(F->getName(), "SSH"));
} else {
StackChkFail =
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 722cefb1eddb3c5..7be1ebe6fa79b04 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1911,7 +1911,7 @@ TargetLoweringBase::getDefaultSafeStackPointerLocation(IRBuilderBase &IRB,
auto UnsafeStackPtr =
dyn_cast_or_null<GlobalVariable>(M->getNamedValue(UnsafeStackPtrVar));
- Type *StackPtrTy = Type::getInt8PtrTy(M->getContext());
+ Type *StackPtrTy = PointerType::getUnqual(M->getContext());
if (!UnsafeStackPtr) {
auto TLSModel = UseTLS ?
@@ -1942,7 +1942,7 @@ TargetLoweringBase::getSafeStackPointerLocation(IRBuilderBase &IRB) const {
// Android provides a libc function to retrieve the address of the current
// thread's unsafe stack pointer.
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
- Type *StackPtrTy = Type::getInt8PtrTy(M->getContext());
+ Type *StackPtrTy = PointerType::getUnqual(M->getContext());
FunctionCallee Fn = M->getOrInsertFunction("__safestack_pointer_address",
StackPtrTy->getPointerTo(0));
return IRB.CreateCall(Fn);
@@ -1998,7 +1998,7 @@ bool TargetLoweringBase::isLegalAddressingMode(const DataLayout &DL,
Value *TargetLoweringBase::getIRStackGuard(IRBuilderBase &IRB) const {
if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
Module &M = *IRB.GetInsertBlock()->getParent()->getParent();
- PointerType *PtrTy = Type::getInt8PtrTy(M.getContext());
+ PointerType *PtrTy = PointerType::getUnqual(M.getContext());
Constant *C = M.getOrInsertGlobal("__guard_local", PtrTy);
if (GlobalVariable *G = dyn_cast_or_null<GlobalVariable>(C))
G->setVisibility(GlobalValue::HiddenVisibility);
@@ -2011,9 +2011,9 @@ Value *TargetLoweringBase::getIRStackGuard(IRBuilderBase &IRB) const {
// TODO: add LOAD_STACK_GUARD support.
void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
if (!M.getNamedValue("__stack_chk_guard")) {
- auto *GV = new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false,
- GlobalVariable::ExternalLinkage, nullptr,
- "__stack_chk_guard");
+ auto *GV = new GlobalVariable(M, PointerType::getUnqual(M.getContext()),
+ false, GlobalVariable::ExternalLinkage,
+ nullptr, "__stack_chk_guard");
// FreeBSD has "__stack_chk_guard" defined externally on libc.so
if (M.getDirectAccessExternalData() &&
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 0d4f9835f0fcd4d..2559ed6a31a6c17 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -340,7 +340,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
Array = std::make_unique<char[]>((InputArgv.size()+1)*PtrSize);
LLVM_DEBUG(dbgs() << "JIT: ARGV = " << (void *)Array.get() << "\n");
- Type *SBytePtr = Type::getInt8PtrTy(C);
+ Type *SBytePtr = PointerType::getUnqual(C);
for (unsigned i = 0; i != InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1;
diff --git a/llvm/lib/Frontend/Offloading/Utility.cpp b/llvm/lib/Frontend/Offloading/Utility.cpp
index 48f0015bac4e345..2a8f1df2cc32ad1 100644
--- a/llvm/lib/Frontend/Offloading/Utility.cpp
+++ b/llvm/lib/Frontend/Offloading/Utility.cpp
@@ -21,10 +21,10 @@ static StructType *getEntryTy(Module &M) {
StructType *EntryTy =
StructType::getTypeByName(C, "struct.__tgt_offload_entry");
if (!EntryTy)
- EntryTy = StructType::create("struct.__tgt_offload_entry",
- Type::getInt8PtrTy(C), Type::getInt8PtrTy(C),
- M.getDataLayout().getIntPtrType(C),
- Type::getInt32Ty(C), Type::getInt32Ty(C));
+ EntryTy = StructType::create(
+ "struct.__tgt_offload_entry", PointerType::getUnqual(C),
+ PointerType::getUnqual(C), M.getDataLayout().getIntPtrType(C),
+ Type::getInt32Ty(C), Type::getInt32Ty(C));
return EntryTy;
}
@@ -32,7 +32,7 @@ static StructType *getEntryTy(Module &M) {
void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name,
uint64_t Size, int32_t Flags,
StringRef SectionName) {
- Type *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+ Type *Int8PtrTy = PointerType::getUnqual(M.getContext());
Type *Int32Ty = Type::getInt32Ty(M.getContext());
Type *SizeTy = M.getDataLayout().getIntPtrType(M.getContext());
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9f0e0ad57c4669b..3b73bb0a9fa4c0a 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1428,22 +1428,63 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
LLVM_DEBUG(dbgs() << "After body codegen: " << *OuterFn << "\n");
OutlineInfo OI;
- if (Config.isTargetDevice()) {
- // Generate OpenMP target specific runtime call
- OI.PostOutlineCB = [=, ToBeDeletedVec =
- std::move(ToBeDeleted)](Function &OutlinedFn) {
- targetParallelCallback(this, OutlinedFn, OuterFn, OuterAllocaBlock, Ident,
- IfCondition, NumThreads, PrivTID, PrivTIDAddr,
- ThreadID, ToBeDeletedVec);
- };
- } else {
- // Generate OpenMP host runtime call
- OI.PostOutlineCB = [=, ToBeDeletedVec =
- std::move(ToBeDeleted)](Function &OutlinedFn) {
- hostParallelCallback(this, OutlinedFn, OuterFn, Ident, IfCondition,
- PrivTID, PrivTIDAddr, ToBeDeletedVec);
- };
- }
+ OI.PostOutlineCB = [=](Function &OutlinedFn) {
+ // Add some known attributes.
+ OutlinedFn.addParamAttr(0, Attribute::NoAlias);
+ OutlinedFn.addParamAttr(1, Attribute::NoAlias);
+ OutlinedFn.addFnAttr(Attribute::NoUnwind);
+ OutlinedFn.addFnAttr(Attribute::NoRecurse);
+
+ assert(OutlinedFn.arg_size() >= 2 &&
+ "Expected at least tid and bounded tid as arguments");
+ unsigned NumCapturedVars =
+ OutlinedFn.arg_size() - /* tid & bounded tid */ 2;
+
+ CallInst *CI = cast<CallInst>(OutlinedFn.user_back());
+ CI->getParent()->setName("omp_parallel");
+ Builder.SetInsertPoint(CI);
+
+ // Build call __kmpc_fork_call[_if](Ident, n, microtask, var1, .., varn);
+ Value *ForkCallArgs[] = {
+ Ident, Builder.getInt32(NumCapturedVars),
+ Builder.CreateBitCast(&OutlinedFn, ParallelTaskPtr)};
+
+ SmallVector<Value *, 16> RealArgs;
+ RealArgs.append(std::begin(ForkCallArgs), std::end(ForkCallArgs));
+ if (IfCondition) {
+ Value *Cond = Builder.CreateSExtOrTrunc(IfCondition,
+ Type::getInt32Ty(M.getContext()));
+ RealArgs.push_back(Cond);
+ }
+ RealArgs.append(CI->arg_begin() + /* tid & bound tid */ 2, CI->arg_end());
+
+ // __kmpc_fork_call_if always expects a void ptr as the last argument
+ // If there are no arguments, pass a null pointer.
+ auto PtrTy = PointerType::getUnqual(M.getContext());
+ if (IfCondition && NumCapturedVars == 0) {
+ llvm::Value *Void = ConstantPointerNull::get(PtrTy);
+ RealArgs.push_back(Void);
+ }
+ if (IfCondition && RealArgs.back()->getType() != PtrTy)
+ RealArgs.back() = Builder.CreateBitCast(RealArgs.back(), PtrTy);
+
+ Builder.CreateCall(RTLFn, RealArgs);
+
+ LLVM_DEBUG(dbgs() << "With fork_call placed: "
+ << *Builder.GetInsertBlock()->getParent() << "\n");
+
+ InsertPointTy ExitIP(PRegExitBB, PRegExitBB->end());
+
+ // Initialize the local TID stack location with the argument value.
+ Builder.SetInsertPoint(PrivTID);
+ Function::arg_iterator OutlinedAI = OutlinedFn.arg_begin();
+ Builder.CreateStore(Builder.CreateLoad(Int32, OutlinedAI), PrivTIDAddr);
+
+ CI->eraseFromParent();
+
+ for (Instruction *I : ToBeDeleted)
+ I->eraseFromParent();
+ };
// Adjust the finalization stack, verify the adjustment, and call the
// finalize function a last time to finalize values between the pre-fini
@@ -1856,7 +1897,7 @@ OpenMPIRBuilder::createTask(const LocationDescription &Loc,
TaskFn,
{Ident, ThreadID, TaskData, Builder.getInt32(Dependencies.size()),
DepArrayPtr, ConstantInt::get(Builder.getInt32Ty(), 0),
- ConstantPointerNull::get(Type::getInt8PtrTy(M.getContext()))});
+ ConstantPointerNull::get(PointerType::getUnqual(M.getContext()))});
} else {
// Emit the @__kmpc_omp_task runtime call to spawn the task
@@ -2047,7 +2088,7 @@ OpenMPIRBuilder::createSection(const LocationDescription &Loc,
/// the given module and return it.
Function *getFreshReductionFunc(Module &M) {
Type *VoidTy = Type::getVoidTy(M.getContext());
- Type *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+ Type *Int8PtrTy = PointerType::getUnqual(M.getContext());
auto *FuncTy =
FunctionType::get(VoidTy, {Int8PtrTy, Int8PtrTy}, /* IsVarArg */ false);
return Function::Create(FuncTy, GlobalVariable::InternalLinkage,
@@ -4128,7 +4169,7 @@ CallInst *OpenMPIRBuilder::createOMPInteropInit(
Constant *InteropTypeVal = ConstantInt::get(Int32, (int)InteropType);
if (NumDependences == nullptr) {
NumDependences = ConstantInt::get(Int32, 0);
- PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+ PointerType *PointerTypeVar = PointerType::getUnqual(M.getContext());
DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
}
Value *HaveNowaitClauseVal = ConstantInt::get(Int32, HaveNowaitClause);
@@ -4155,7 +4196,7 @@ CallInst *OpenMPIRBuilder::createOMPInteropDestroy(
Device = ConstantInt::get(Int32, -1);
if (NumDependences == nullptr) {
NumDependences = ConstantInt::get(Int32, 0);
- PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+ PointerType *PointerTypeVar = PointerType::getUnqual(M.getContext());
DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
}
Value *HaveNowaitClauseVal = ConstantInt::get(Int32, HaveNowaitClause);
@@ -4183,7 +4224,7 @@ CallInst *OpenMPIRBuilder::createOMPInteropUse(const LocationDescription &Loc,
Device = ConstantInt::get(Int32, -1);
if (NumDependences == nullptr) {
NumDependences = ConstantInt::get(Int32, 0);
- PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+ PointerType *PointerTypeVar = PointerType::getUnqual(M.getContext());
DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
}
Value *HaveNowaitClauseVal = ConstantInt::get(Int32, HaveNowaitClause);
@@ -4756,7 +4797,7 @@ static Function *createOutlinedFunction(
if (OMPBuilder.Config.isTargetDevice()) {
// Add the "implicit" runtime argument we use to provide launch specific
// information for target devices.
- auto *Int8PtrTy = Type::getInt8PtrTy(Builder.getContext());
+ auto *Int8PtrTy = PointerType::getUnqual(Builder.getContext());
ParameterTypes.push_back(Int8PtrTy);
// All parameters to target devices are passed as pointers
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 006278d16484c1c..8a1bf9654fdc6eb 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -256,10 +256,6 @@ IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) {
return IntegerType::get(C, N);
}
-PointerType *Type::getInt8PtrTy(LLVMContext &C, unsigned AS) {
- return PointerType::get(C, AS);
-}
-
Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
// opaque pointer in addrspace(10)
static PointerType *Ty = PointerType::get(C, 10);
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index f5193a9f2adf30c..24e836c41eaf96b 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -24870,12 +24870,13 @@ void AArch64TargetLowering::insertSSPDeclarations(Module &M) const {
if (Subtarget->getTargetTriple().isWindowsMSVCEnvironment()) {
// MSVC CRT has a global variable holding security cookie.
M.getOrInsertGlobal("__security_cookie",
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
// MSVC CRT has a function to validate security cookie.
- FunctionCallee SecurityCheckCookie = M.getOrInsertFunction(
- Subtarget->getSecurityCheckCookieName(),
- Type::getVoidTy(M.getContext()), Type::getInt8PtrTy(M.getContext()));
+ FunctionCallee SecurityCheckCookie =
+ M.getOrInsertFunction(Subtarget->getSecurityCheckCookieName(),
+ Type::getVoidTy(M.getContext()),
+ PointerType::getUnqual(M.getContext()));
if (Function *F = dyn_cast<Function>(SecurityCheckCookie.getCallee())) {
F->setCallingConv(CallingConv::Win64);
F->addParamAttr(0, Attribute::AttrKind::InReg);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index efe40e52065426d..a93acc6b4e67987 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -854,7 +854,7 @@ class AMDGPULowerModuleLDS {
appendToCompilerUsed(M, {static_cast<GlobalValue *>(
ConstantExpr::getPointerBitCastOrAddrSpaceCast(
cast<Constant>(ModuleScopeReplacement.SGV),
- Type::getInt8PtrTy(Ctx)))});
+ PointerType::getUnqual(Ctx)))});
// module.lds will be allocated at zero in any kernel that allocates it
recordLDSAbsoluteAddress(&M, ModuleScopeReplacement.SGV, 0);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp
index 67624b325fb0c63..4f5ca08b46c1399 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp
@@ -92,9 +92,9 @@ bool AMDGPUOpenCLEnqueuedBlockLowering::runOnModule(Module &M) {
auto RuntimeHandle = (F.getName() + ".runtime_handle").str();
if (!HandleTy) {
Type *Int32 = Type::getInt32Ty(C);
- HandleTy = StructType::create(
- C, {Type::getInt8PtrTy(C), Int32, Int32},
- "block.runtime.handle.t");
+ HandleTy =
+ StructType::create(C, {PointerType::getUnqual(C), Int32, Int32},
+ "block.runtime.handle.t");
}
auto *GV = new GlobalVariable(
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 9fe5dd55a810c4b..45d04c0669aea06 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -21371,12 +21371,12 @@ void ARMTargetLowering::insertSSPDeclarations(Module &M) const {
// MSVC CRT has a global variable holding security cookie.
M.getOrInsertGlobal("__security_cookie",
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
// MSVC CRT has a function to validate security cookie.
FunctionCallee SecurityCheckCookie = M.getOrInsertFunction(
"__security_check_cookie", Type::getVoidTy(M.getContext()),
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
if (Function *F = dyn_cast<Function>(SecurityCheckCookie.getCallee()))
F->addParamAttr(0, Attribute::AttrKind::InReg);
}
diff --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
index a878eaabe00ff5e..06ed9defc59be44 100644
--- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -1108,7 +1108,8 @@ bool BPFAbstractMemberAccess::transformGEPChain(CallInst *Call,
auto *LDInst = new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "", Call);
// Generate a BitCast
- auto *BCInst = new BitCastInst(Base, Type::getInt8PtrTy(BB->getContext()));
+ auto *BCInst =
+ new BitCastInst(Base, PointerType::getUnqual(BB->getContext()));
BCInst->insertBefore(Call);
// Generate a GetElementPtr
diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
index 905756469902569..59fe6d45757aade 100644
--- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
@@ -183,7 +183,8 @@ static StructType *getResRetType(Type *OverloadTy, LLVMContext &Ctx) {
}
static StructType *getHandleType(LLVMContext &Ctx) {
- return getOrCreateStructType("dx.types.Handle", Type::getInt8PtrTy(Ctx), Ctx);
+ return getOrCreateStructType("dx.types.Handle", PointerType::getUnqual(Ctx),
+ Ctx);
}
static Type *getTypeFromParameterKind(ParameterKind Kind, Type *OverloadTy) {
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 5e0c2d62f5a9cb5..07e6ee97b4ee047 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -17501,7 +17501,7 @@ bool PPCTargetLowering::useLoadStackGuardNode() const {
void PPCTargetLowering::insertSSPDeclarations(Module &M) const {
if (Subtarget.isAIXABI()) {
M.getOrInsertGlobal(AIXSSPCanaryWordName,
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
return;
}
if (!Subtarget.isTargetLinux())
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ec72cee0c392d50..22fba5601ccfd38 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -30310,7 +30310,7 @@ void X86TargetLowering::emitBitTestAtomicRMWIntrinsic(AtomicRMWInst *AI) const {
Instruction *I = AI->user_back();
LLVMContext &Ctx = AI->getContext();
Value *Addr = Builder.CreatePointerCast(AI->getPointerOperand(),
- Type::getInt8PtrTy(Ctx));
+ PointerType::getUnqual(Ctx));
Function *BitTest = nullptr;
Value *Result = nullptr;
auto BitTested = FindSingleBitChange(AI->getValOperand());
@@ -30479,7 +30479,7 @@ void X86TargetLowering::emitCmpArithAtomicRMWIntrinsic(
Function *CmpArith =
Intrinsic::getDeclaration(AI->getModule(), IID, AI->getType());
Value *Addr = Builder.CreatePointerCast(AI->getPointerOperand(),
- Type::getInt8PtrTy(Ctx));
+ PointerType::getUnqual(Ctx));
Value *Call = Builder.CreateCall(
CmpArith, {Addr, AI->getValOperand(), Builder.getInt32((unsigned)CC)});
Value *Result = Builder.CreateTrunc(Call, Type::getInt1Ty(Ctx));
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
index 2fe145f9267de87..b8b5421b9005018 100644
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
@@ -622,12 +622,12 @@ void X86TargetLowering::insertSSPDeclarations(Module &M) const {
Subtarget.getTargetTriple().isWindowsItaniumEnvironment()) {
// MSVC CRT has a global variable holding security cookie.
M.getOrInsertGlobal("__security_cookie",
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
// MSVC CRT has a function to validate security cookie.
FunctionCallee SecurityCheckCookie = M.getOrInsertFunction(
"__security_check_cookie", Type::getVoidTy(M.getContext()),
- Type::getInt8PtrTy(M.getContext()));
+ PointerType::getUnqual(M.getContext()));
if (Function *F = dyn_cast<Function>(SecurityCheckCookie.getCallee())) {
F->setCallingConv(CallingConv::X86_FastCall);
F->addParamAttr(0, Attribute::AttrKind::InReg);
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index 15ad2d60e889f6f..11d9509c707b33b 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -172,7 +172,7 @@ bool WinEHStatePass::runOnFunction(Function &F) {
if (!HasPads)
return false;
- Type *Int8PtrType = Type::getInt8PtrTy(TheModule->getContext());
+ Type *Int8PtrType = PointerType::getUnqual(TheModule->getContext());
SetJmp3 = TheModule->getOrInsertFunction(
"_setjmp3", FunctionType::get(
Type::getInt32Ty(TheModule->getContext()),
@@ -214,7 +214,7 @@ Type *WinEHStatePass::getEHLinkRegistrationType() {
Type *FieldTys[] = {
PointerType::getUnqual(
EHLinkRegistrationTy->getContext()), // EHRegistrationNode *Next
- Type::getInt8PtrTy(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
+ PointerType::getUnqual(Context) // EXCEPTION_DISPOSITION (*Handler)(...)
};
EHLinkRegistrationTy->setBody(FieldTys, false);
return EHLinkRegistrationTy;
@@ -231,9 +231,9 @@ Type *WinEHStatePass::getCXXEHRegistrationType() {
return CXXEHRegistrationTy;
LLVMContext &Context = TheModule->getContext();
Type *FieldTys[] = {
- Type::getInt8PtrTy(Context), // void *SavedESP
- getEHLinkRegistrationType(), // EHRegistrationNode SubRecord
- Type::getInt32Ty(Context) // int32_t TryLevel
+ PointerType::getUnqual(Context), // void *SavedESP
+ getEHLinkRegistrationType(), // EHRegistrationNode SubRecord
+ Type::getInt32Ty(Context) // int32_t TryLevel
};
CXXEHRegistrationTy =
StructType::create(FieldTys, "CXXExceptionRegistration");
@@ -253,11 +253,11 @@ Type *WinEHStatePass::getSEHRegistrationType() {
return SEHRegistrationTy;
LLVMContext &Context = TheModule->getContext();
Type *FieldTys[] = {
- Type::getInt8PtrTy(Context), // void *SavedESP
- Type::getInt8PtrTy(Context), // void *ExceptionPointers
- getEHLinkRegistrationType(), // EHRegistrationNode SubRecord
- Type::getInt32Ty(Context), // int32_t EncodedScopeTable
- Type::getInt32Ty(Context) // int32_t TryLevel
+ PointerType::getUnqual(Context), // void *SavedESP
+ PointerType::getUnqual(Context), // void *ExceptionPointers
+ getEHLinkRegistrationType(), // EHRegistrationNode SubRecord
+ Type::getInt32Ty(Context), // int32_t EncodedScopeTable
+ Type::getInt32Ty(Context) // int32_t TryLevel
};
SEHRegistrationTy = StructType::create(FieldTys, "SEHExceptionRegistration");
return SEHRegistrationTy;
@@ -383,7 +383,7 @@ Value *WinEHStatePass::emitEHLSDA(IRBuilder<> &Builder, Function *F) {
Function *WinEHStatePass::generateLSDAInEAXThunk(Function *ParentFunc) {
LLVMContext &Context = ParentFunc->getContext();
Type *Int32Ty = Type::getInt32Ty(Context);
- Type *Int8PtrType = Type::getInt8PtrTy(Context);
+ Type *Int8PtrType = PointerType::getUnqual(Context);
Type *ArgTys[5] = {Int8PtrType, Int8PtrType, Int8PtrType, Int8PtrType,
Int8PtrType};
FunctionType *TrampolineTy =
diff --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
index 4604bcc14ee20df..4f4fccd80f7608c 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
@@ -292,7 +292,7 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
return GA;
} else {
// Ideally we would not fold in offset with an index <= 11.
- Type *Ty = Type::getInt8PtrTy(*DAG.getContext());
+ Type *Ty = PointerType::getUnqual(*DAG.getContext());
Constant *GA = ConstantExpr::getBitCast(const_cast<GlobalValue*>(GV), Ty);
Ty = Type::getInt32Ty(*DAG.getContext());
Constant *Idx = ConstantInt::get(Ty, Offset);
diff --git a/llvm/lib/Transforms/CFGuard/CFGuard.cpp b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
index 3eca0e4b5947327..b043879359ac349 100644
--- a/llvm/lib/Transforms/CFGuard/CFGuard.cpp
+++ b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
@@ -235,8 +235,9 @@ bool CFGuard::doInitialization(Module &M) {
return false;
// Set up prototypes for the guard check and dispatch functions.
- GuardFnType = FunctionType::get(Type::getVoidTy(M.getContext()),
- {Type::getInt8PtrTy(M.getContext())}, false);
+ GuardFnType =
+ FunctionType::get(Type::getVoidTy(M.getContext()),
+ {PointerType::getUnqual(M.getContext())}, false);
GuardFnPtrType = PointerType::get(GuardFnType, 0);
// Get or insert the guard check or dispatch global symbols.
diff --git a/llvm/lib/Transforms/Coroutines/CoroElide.cpp b/llvm/lib/Transforms/Coroutines/CoroElide.cpp
index 3310a0a7657f750..2f4083028ae0546 100644
--- a/llvm/lib/Transforms/Coroutines/CoroElide.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroElide.cpp
@@ -165,7 +165,7 @@ void Lowerer::elideHeapAllocations(Function *F, uint64_t FrameSize,
auto *Frame = new AllocaInst(FrameTy, DL.getAllocaAddrSpace(), "", InsertPt);
Frame->setAlignment(FrameAlign);
auto *FrameVoidPtr =
- new BitCastInst(Frame, Type::getInt8PtrTy(C), "vFrame", InsertPt);
+ new BitCastInst(Frame, PointerType::getUnqual(C), "vFrame", InsertPt);
for (auto *CB : CoroBegins) {
CB->replaceAllUsesWith(FrameVoidPtr);
diff --git a/llvm/lib/Transforms/Coroutines/CoroInstr.h b/llvm/lib/Transforms/Coroutines/CoroInstr.h
index 2e7d9b2ce028a3e..95e30a2a569ff22 100644
--- a/llvm/lib/Transforms/Coroutines/CoroInstr.h
+++ b/llvm/lib/Transforms/Coroutines/CoroInstr.h
@@ -123,8 +123,8 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
void clearPromise() {
Value *Arg = getArgOperand(PromiseArg);
- setArgOperand(PromiseArg,
- ConstantPointerNull::get(Type::getInt8PtrTy(getContext())));
+ setArgOperand(PromiseArg, ConstantPointerNull::get(
+ PointerType::getUnqual(getContext())));
if (isa<AllocaInst>(Arg))
return;
assert((isa<BitCastInst>(Arg) || isa<GetElementPtrInst>(Arg)) &&
@@ -185,7 +185,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
void setCoroutineSelf() {
assert(isa<ConstantPointerNull>(getArgOperand(CoroutineArg)) &&
"Coroutine argument is already assigned");
- auto *const Int8PtrTy = Type::getInt8PtrTy(getContext());
+ auto *const Int8PtrTy = PointerType::getUnqual(getContext());
setArgOperand(CoroutineArg,
ConstantExpr::getBitCast(getFunction(), Int8PtrTy));
}
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index e3eb8c4d8f1dc11..c7bc104a5b9a507 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1096,7 +1096,7 @@ void CoroCloner::create() {
// Remap vFrame pointer.
auto *NewVFrame = Builder.CreateBitCast(
- NewFramePtr, Type::getInt8PtrTy(Builder.getContext()), "vFrame");
+ NewFramePtr, PointerType::getUnqual(Builder.getContext()), "vFrame");
Value *OldVFrame = cast<Value>(VMap[Shape.CoroBegin]);
if (OldVFrame != NewVFrame)
OldVFrame->replaceAllUsesWith(NewVFrame);
@@ -1227,7 +1227,7 @@ static void setCoroInfo(Function &F, coro::Shape &Shape,
// Update coro.begin instruction to refer to this constant.
LLVMContext &C = F.getContext();
- auto *BC = ConstantExpr::getPointerCast(GV, Type::getInt8PtrTy(C));
+ auto *BC = ConstantExpr::getPointerCast(GV, PointerType::getUnqual(C));
Shape.getSwitchCoroId()->setInfo(BC);
}
@@ -1707,7 +1707,7 @@ static void replaceAsyncResumeFunction(CoroSuspendAsyncInst *Suspend,
Value *Continuation) {
auto *ResumeIntrinsic = Suspend->getResumeFunction();
auto &Context = Suspend->getParent()->getParent()->getContext();
- auto *Int8PtrTy = Type::getInt8PtrTy(Context);
+ auto *Int8PtrTy = PointerType::getUnqual(Context);
IRBuilder<> Builder(ResumeIntrinsic);
auto *Val = Builder.CreateBitOrPointerCast(Continuation, Int8PtrTy);
@@ -1760,7 +1760,7 @@ static void splitAsyncCoroutine(Function &F, coro::Shape &Shape,
F.removeRetAttr(Attribute::NonNull);
auto &Context = F.getContext();
- auto *Int8PtrTy = Type::getInt8PtrTy(Context);
+ auto *Int8PtrTy = PointerType::getUnqual(Context);
auto *Id = cast<CoroIdAsyncInst>(Shape.CoroBegin->getId());
IRBuilder<> Builder(Id);
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index c8d7138327fbfdd..5c2763850ac6540 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -660,7 +660,7 @@ struct AddressSanitizer {
DL = &M.getDataLayout();
LongSize = M.getDataLayout().getPointerSizeInBits();
IntptrTy = Type::getIntNTy(*C, LongSize);
- Int8PtrTy = Type::getInt8PtrTy(*C);
+ Int8PtrTy = PointerType::getUnqual(*C);
Int32Ty = Type::getInt32Ty(*C);
TargetTriple = Triple(M.getTargetTriple());
@@ -1571,7 +1571,7 @@ void AddressSanitizer::instrumentMaskedLoadOrStore(
InstrumentedAddress = IRB.CreateExtractElement(Addr, Index);
} else if (Stride) {
Index = IRB.CreateMul(Index, Stride);
- Addr = IRB.CreateBitCast(Addr, Type::getInt8PtrTy(*C));
+ Addr = IRB.CreateBitCast(Addr, PointerType::getUnqual(*C));
InstrumentedAddress = IRB.CreateGEP(Type::getInt8Ty(*C), Addr, {Index});
} else {
InstrumentedAddress = IRB.CreateGEP(VTy, Addr, {Zero, Index});
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index adc0beed4d9a13a..3c66ebc7db3d804 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -1145,7 +1145,7 @@ bool DataFlowSanitizer::initializeModule(Module &M) {
Mod = &M;
Ctx = &M.getContext();
- Int8Ptr = Type::getInt8PtrTy(*Ctx);
+ Int8Ptr = PointerType::getUnqual(*Ctx);
OriginTy = IntegerType::get(*Ctx, OriginWidthBits);
OriginPtrTy = PointerType::getUnqual(OriginTy);
PrimitiveShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
@@ -1162,19 +1162,19 @@ bool DataFlowSanitizer::initializeModule(Module &M) {
FunctionType::get(IntegerType::get(*Ctx, 64), DFSanLoadLabelAndOriginArgs,
/*isVarArg=*/false);
DFSanUnimplementedFnTy = FunctionType::get(
- Type::getVoidTy(*Ctx), Type::getInt8PtrTy(*Ctx), /*isVarArg=*/false);
+ Type::getVoidTy(*Ctx), PointerType::getUnqual(*Ctx), /*isVarArg=*/false);
Type *DFSanWrapperExternWeakNullArgs[2] = {Int8Ptr, Int8Ptr};
DFSanWrapperExternWeakNullFnTy =
FunctionType::get(Type::getVoidTy(*Ctx), DFSanWrapperExternWeakNullArgs,
/*isVarArg=*/false);
Type *DFSanSetLabelArgs[4] = {PrimitiveShadowTy, OriginTy,
- Type::getInt8PtrTy(*Ctx), IntptrTy};
+ PointerType::getUnqual(*Ctx), IntptrTy};
DFSanSetLabelFnTy = FunctionType::get(Type::getVoidTy(*Ctx),
DFSanSetLabelArgs, /*isVarArg=*/false);
DFSanNonzeroLabelFnTy = FunctionType::get(Type::getVoidTy(*Ctx), std::nullopt,
/*isVarArg=*/false);
DFSanVarargWrapperFnTy = FunctionType::get(
- Type::getVoidTy(*Ctx), Type::getInt8PtrTy(*Ctx), /*isVarArg=*/false);
+ Type::getVoidTy(*Ctx), PointerType::getUnqual(*Ctx), /*isVarArg=*/false);
DFSanConditionalCallbackFnTy =
FunctionType::get(Type::getVoidTy(*Ctx), PrimitiveShadowTy,
/*isVarArg=*/false);
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 5d66895d0e207e2..6131d3a3781f6d0 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -1031,9 +1031,9 @@ void GCOVProfiler::emitGlobalConstructor(
FunctionCallee GCOVProfiler::getStartFileFunc(const TargetLibraryInfo *TLI) {
Type *Args[] = {
- Type::getInt8PtrTy(*Ctx), // const char *orig_filename
- Type::getInt32Ty(*Ctx), // uint32_t version
- Type::getInt32Ty(*Ctx), // uint32_t checksum
+ PointerType::getUnqual(*Ctx), // const char *orig_filename
+ Type::getInt32Ty(*Ctx), // uint32_t version
+ Type::getInt32Ty(*Ctx), // uint32_t checksum
};
FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false);
return M->getOrInsertFunction("llvm_gcda_start_file", FTy,
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index de4a3adacb12923..eadf1cd9baccc60 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -817,7 +817,7 @@ void InstrProfiling::lowerMCDCTestVectorBitmapUpdate(
InstrProfMCDCTVBitmapUpdate *Update) {
IRBuilder<> Builder(Update);
auto *Int8Ty = Type::getInt8Ty(M->getContext());
- auto *Int8PtrTy = Type::getInt8PtrTy(M->getContext());
+ auto *Int8PtrTy = PointerType::getUnqual(M->getContext());
auto *Int32Ty = Type::getInt32Ty(M->getContext());
auto *Int64Ty = Type::getInt64Ty(M->getContext());
auto *MCDCCondBitmapAddr = Update->getMCDCCondBitmapAddr();
@@ -1002,7 +1002,7 @@ static inline bool shouldUsePublicSymbol(Function *Fn) {
}
static inline Constant *getFuncAddrForProfData(Function *Fn) {
- auto *Int8PtrTy = Type::getInt8PtrTy(Fn->getContext());
+ auto *Int8PtrTy = PointerType::getUnqual(Fn->getContext());
// Store a nullptr in __llvm_profd, if we shouldn't use a real address
if (!shouldRecordFunctionAddr(Fn))
return ConstantPointerNull::get(Int8PtrTy);
@@ -1277,7 +1277,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
std::string DataVarName =
getVarName(Inc, getInstrProfDataVarPrefix(), Renamed);
- auto *Int8PtrTy = Type::getInt8PtrTy(Ctx);
+ auto *Int8PtrTy = PointerType::getUnqual(Ctx);
// Allocate statically the array of pointers to value profile nodes for
// the current function.
Constant *ValuesPtrExpr = ConstantPointerNull::get(Int8PtrTy);
@@ -1296,7 +1296,7 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
ValuesVar->setAlignment(Align(8));
maybeSetComdat(ValuesVar, Fn, CntsVarName);
ValuesPtrExpr =
- ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx));
+ ConstantExpr::getBitCast(ValuesVar, PointerType::getUnqual(Ctx));
}
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
@@ -1469,7 +1469,7 @@ void InstrProfiling::emitRegistration() {
// Construct the function.
auto *VoidTy = Type::getVoidTy(M->getContext());
- auto *VoidPtrTy = Type::getInt8PtrTy(M->getContext());
+ auto *VoidPtrTy = PointerType::getUnqual(M->getContext());
auto *Int64Ty = Type::getInt64Ty(M->getContext());
auto *RegisterFTy = FunctionType::get(VoidTy, false);
auto *RegisterF = Function::Create(RegisterFTy, GlobalValue::InternalLinkage,
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 49608768f8ba68a..7477e1b647df92a 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -875,7 +875,7 @@ static void instrumentOneFunc(
F, TLI, ComdatMembers, true, BPI, BFI, IsCS, PGOInstrumentEntry,
PGOBlockCoverage);
- Type *I8PtrTy = Type::getInt8PtrTy(M->getContext());
+ Type *I8PtrTy = PointerType::getUnqual(M->getContext());
auto Name = ConstantExpr::getBitCast(FuncInfo.FuncNameVar, I8PtrTy);
auto CFGHash = ConstantInt::get(Type::getInt64Ty(M->getContext()),
FuncInfo.FunctionHash);
diff --git a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
index 7c2770979a900fa..cc1f56014eee984 100644
--- a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp
@@ -399,7 +399,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) {
continue;
unsigned PtrAddrSpace = NextLSCEV->getType()->getPointerAddressSpace();
- Type *I8Ptr = Type::getInt8PtrTy(BB->getContext(), PtrAddrSpace);
+ Type *I8Ptr = PointerType::get(BB->getContext(), PtrAddrSpace);
Value *PrefPtrValue = SCEVE.expandCodeFor(NextLSCEV, I8Ptr, P.InsertPt);
IRBuilder<> Builder(P.InsertPt);
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 63ee11295e9c032..21c2b8aa9485fd1 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1514,7 +1514,7 @@ static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
auto getGCRelocateDecl = [&](Type *Ty) {
assert(isHandledGCPointerType(Ty, GC));
auto AS = Ty->getScalarType()->getPointerAddressSpace();
- Type *NewTy = Type::getInt8PtrTy(M->getContext(), AS);
+ Type *NewTy = PointerType::get(M->getContext(), AS);
if (auto *VT = dyn_cast<VectorType>(Ty))
NewTy = FixedVectorType::get(NewTy,
cast<FixedVectorType>(VT)->getNumElements());
diff --git a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
index fdb41cb415df8ea..543469d62fe732b 100644
--- a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
@@ -680,7 +680,7 @@ void StraightLineStrengthReduce::rewriteCandidateWithBasis(
if (BumpWithUglyGEP) {
// C = (char *)Basis + Bump
unsigned AS = Basis.Ins->getType()->getPointerAddressSpace();
- Type *CharTy = Type::getInt8PtrTy(Basis.Ins->getContext(), AS);
+ Type *CharTy = PointerType::get(Basis.Ins->getContext(), AS);
Reduced = Builder.CreateBitCast(Basis.Ins, CharTy);
Reduced =
Builder.CreateGEP(Builder.getInt8Ty(), Reduced, Bump, "", InBounds);
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 32f1bb1db9c3547..650085417c45e85 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -568,7 +568,7 @@ void CodeExtractor::findAllocas(const CodeExtractorAnalysisCache &CEAC,
for (Instruction *I : LifetimeBitcastUsers) {
Module *M = AIFunc->getParent();
LLVMContext &Ctx = M->getContext();
- auto *Int8PtrTy = Type::getInt8PtrTy(Ctx);
+ auto *Int8PtrTy = PointerType::getUnqual(Ctx);
CastInst *CastI =
CastInst::CreatePointerCast(AI, Int8PtrTy, "lt.cast", I);
I->replaceUsesOfWith(I->getOperand(1), CastI);
diff --git a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
index d2dbfcfd89d1626..b6e39c6af9eec26 100644
--- a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -54,7 +54,7 @@ static void insertCall(Function &CurFn, StringRef Func,
}
if (Func == "__cyg_profile_func_enter" || Func == "__cyg_profile_func_exit") {
- Type *ArgTypes[] = {Type::getInt8PtrTy(C), Type::getInt8PtrTy(C)};
+ Type *ArgTypes[] = {PointerType::getUnqual(C), PointerType::getUnqual(C)};
FunctionCallee Fn = M.getOrInsertFunction(
Func, FunctionType::get(Type::getVoidTy(C), ArgTypes, false));
@@ -65,8 +65,8 @@ static void insertCall(Function &CurFn, StringRef Func,
InsertionPt);
RetAddr->setDebugLoc(DL);
- Value *Args[] = {ConstantExpr::getBitCast(&CurFn, Type::getInt8PtrTy(C)),
- RetAddr};
+ Value *Args[] = {
+ ConstantExpr::getBitCast(&CurFn, PointerType::getUnqual(C)), RetAddr};
CallInst *Call =
CallInst::Create(Fn, ArrayRef<Value *>(Args), "", InsertionPt);
diff --git a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
index 88c838685bca186..cc00106fcbfe070 100644
--- a/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
+++ b/llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
@@ -70,7 +70,7 @@ IRBuilder<> *EscapeEnumerator::Next() {
// Create a cleanup block.
LLVMContext &C = F.getContext();
BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
- Type *ExnTy = StructType::get(Type::getInt8PtrTy(C), Type::getInt32Ty(C));
+ Type *ExnTy = StructType::get(PointerType::getUnqual(C), Type::getInt32Ty(C));
if (!F.hasPersonalityFn()) {
FunctionCallee PersFn = getDefaultPersonalityFn(F.getParent());
F.setPersonalityFn(cast<Constant>(PersFn.getCallee()));
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 7ea51aab7dc1fc0..4749b213ee56c19 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1608,8 +1608,8 @@ static bool isUsedByLifetimeMarker(Value *V) {
// lifetime.start or lifetime.end intrinsics.
static bool hasLifetimeMarkers(AllocaInst *AI) {
Type *Ty = AI->getType();
- Type *Int8PtrTy = Type::getInt8PtrTy(Ty->getContext(),
- Ty->getPointerAddressSpace());
+ Type *Int8PtrTy =
+ PointerType::get(Ty->getContext(), Ty->getPointerAddressSpace());
if (Ty == Int8PtrTy)
return isUsedByLifetimeMarker(AI);
diff --git a/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp b/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
index f67a1eb53b8976a..4908535cba54111 100644
--- a/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
+++ b/llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
@@ -128,7 +128,7 @@ static bool runImpl(Module &M) {
// extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
LLVMContext &C = M.getContext();
- PointerType *VoidStar = Type::getInt8PtrTy(C);
+ PointerType *VoidStar = PointerType::getUnqual(C);
Type *AtExitFuncArgs[] = {VoidStar};
FunctionType *AtExitFuncTy =
FunctionType::get(Type::getVoidTy(C), AtExitFuncArgs,
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 6059d6d97205e06..a3737d428a00b5f 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -96,7 +96,7 @@ static void appendToUsedList(Module &M, StringRef Name, ArrayRef<GlobalValue *>
if (GV)
GV->eraseFromParent();
- Type *ArrayEltTy = llvm::Type::getInt8PtrTy(M.getContext());
+ Type *ArrayEltTy = llvm::PointerType::getUnqual(M.getContext());
for (auto *V : Values)
Init.insert(ConstantExpr::getPointerBitCastOrAddrSpaceCast(V, ArrayEltTy));
diff --git a/llvm/lib/Transforms/Utils/SanitizerStats.cpp b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
index fd21ee4cc408fb3..f780b4567bd28d3 100644
--- a/llvm/lib/Transforms/Utils/SanitizerStats.cpp
+++ b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
@@ -21,7 +21,7 @@
using namespace llvm;
SanitizerStatReport::SanitizerStatReport(Module *M) : M(M) {
- StatTy = ArrayType::get(Type::getInt8PtrTy(M->getContext()), 2);
+ StatTy = ArrayType::get(PointerType::getUnqual(M->getContext()), 2);
EmptyModuleStatsTy = makeModuleStatsTy();
ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false,
@@ -33,9 +33,10 @@ ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() {
}
StructType *SanitizerStatReport::makeModuleStatsTy() {
- return StructType::get(M->getContext(), {Type::getInt8PtrTy(M->getContext()),
- Type::getInt32Ty(M->getContext()),
- makeModuleStatsArrayTy()});
+ return StructType::get(M->getContext(),
+ {PointerType::getUnqual(M->getContext()),
+ Type::getInt32Ty(M->getContext()),
+ makeModuleStatsArrayTy()});
}
void SanitizerStatReport::create(IRBuilder<> &B, SanitizerStatKind SK) {
@@ -73,7 +74,7 @@ void SanitizerStatReport::finish() {
return;
}
- PointerType *Int8PtrTy = Type::getInt8PtrTy(M->getContext());
+ PointerType *Int8PtrTy = PointerType::getUnqual(M->getContext());
IntegerType *Int32Ty = Type::getInt32Ty(M->getContext());
Type *VoidTy = Type::getVoidTy(M->getContext());
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index 38821949d0ff034..130c6fabd2d48dc 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -830,8 +830,8 @@ CleanupAndPrepareModules(BugDriver &BD, std::unique_ptr<Module> Test,
// Add the resolver to the Safe module.
// Prototype: void *getPointerToNamedFunction(const char* Name)
FunctionCallee resolverFunc = Safe->getOrInsertFunction(
- "getPointerToNamedFunction", Type::getInt8PtrTy(Safe->getContext()),
- Type::getInt8PtrTy(Safe->getContext()));
+ "getPointerToNamedFunction", PointerType::getUnqual(Safe->getContext()),
+ PointerType::getUnqual(Safe->getContext()));
// Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index d0bca9d1004d994..309fe277e03fac7 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1202,9 +1202,9 @@ TEST_F(CGSCCPassManagerTest, TestAnalysisInvalidationCGSCCUpdate) {
assert(H3F.getName() == "h3" && "Wrong called function!");
H2F.begin()->begin()->eraseFromParent();
// Insert a bitcast of `h3` so that we retain a ref edge to it.
- (void)CastInst::CreatePointerCast(&H3F,
- Type::getInt8PtrTy(H2F.getContext()),
- "dummy", &*H2F.begin()->begin());
+ (void)CastInst::CreatePointerCast(
+ &H3F, PointerType::getUnqual(H2F.getContext()), "dummy",
+ &*H2F.begin()->begin());
// Now update the call graph.
auto &NewC =
@@ -1633,7 +1633,8 @@ TEST_F(CGSCCPassManagerTest, TestUpdateCGAndAnalysisManagerForPasses8) {
// Create an unsused constant that is referencing the old (=replaced)
// function.
- ConstantExpr::getBitCast(FnF, Type::getInt8PtrTy(FnF->getContext()));
+ ConstantExpr::getBitCast(FnF,
+ PointerType::getUnqual(FnF->getContext()));
// Use the CallGraphUpdater to update the call graph.
CallGraphUpdater CGU;
@@ -1763,11 +1764,11 @@ TEST_F(CGSCCPassManagerTest, TestInsertionOfNewFunctions1) {
F.getEntryBlock().front().eraseFromParent();
// 2. Insert a ref edge from 'f' to 'f'.
(void)CastInst::CreatePointerCast(
- &F, Type::getInt8PtrTy(F.getContext()), "f.ref",
+ &F, PointerType::getUnqual(F.getContext()), "f.ref",
&F.getEntryBlock().front());
// 3. Insert a ref edge from 'f' to 'g'.
(void)CastInst::CreatePointerCast(
- G, Type::getInt8PtrTy(F.getContext()), "g.ref",
+ G, PointerType::getUnqual(F.getContext()), "g.ref",
&F.getEntryBlock().front());
CG.addSplitFunction(F, *G);
@@ -1844,18 +1845,20 @@ TEST_F(CGSCCPassManagerTest, TestInsertionOfNewFunctions2) {
BasicBlock::Create(F.getParent()->getContext(), "entry", H1);
BasicBlock *H2BB =
BasicBlock::Create(F.getParent()->getContext(), "entry", H2);
- (void)CastInst::CreatePointerCast(H2, Type::getInt8PtrTy(F.getContext()),
- "h2.ref", H1BB);
+ (void)CastInst::CreatePointerCast(
+ H2, PointerType::getUnqual(F.getContext()), "h2.ref", H1BB);
(void)ReturnInst::Create(H1->getContext(), H1BB);
- (void)CastInst::CreatePointerCast(H1, Type::getInt8PtrTy(F.getContext()),
- "h1.ref", H2BB);
+ (void)CastInst::CreatePointerCast(
+ H1, PointerType::getUnqual(F.getContext()), "h1.ref", H2BB);
(void)ReturnInst::Create(H2->getContext(), H2BB);
// Add 'f -> h1' ref edge.
- (void)CastInst::CreatePointerCast(H1, Type::getInt8PtrTy(F.getContext()),
+ (void)CastInst::CreatePointerCast(H1,
+ PointerType::getUnqual(F.getContext()),
"h1.ref", &F.getEntryBlock().front());
// Add 'f -> h2' ref edge.
- (void)CastInst::CreatePointerCast(H2, Type::getInt8PtrTy(F.getContext()),
+ (void)CastInst::CreatePointerCast(H2,
+ PointerType::getUnqual(F.getContext()),
"h2.ref", &F.getEntryBlock().front());
CG.addSplitRefRecursiveFunctions(F, SmallVector<Function *, 2>({H1, H2}));
diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
index 7eb6932ffb1f199..6ef31042b6003f2 100644
--- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
@@ -2392,7 +2392,7 @@ TEST(LazyCallGraphTest, AddSplitFunction2) {
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2431,7 +2431,8 @@ TEST(LazyCallGraphTest, AddSplitFunction3) {
F.getAddressSpace(), "g", F.getParent());
BasicBlock *GBB = BasicBlock::Create(Context, "", G);
// Create g -ref-> f.
- (void)CastInst::CreatePointerCast(&F, Type::getInt8PtrTy(Context), "", GBB);
+ (void)CastInst::CreatePointerCast(&F, PointerType::getUnqual(Context), "",
+ GBB);
(void)ReturnInst::Create(Context, GBB);
// Create f -call-> g.
@@ -2475,11 +2476,12 @@ TEST(LazyCallGraphTest, AddSplitFunction4) {
F.getAddressSpace(), "g", F.getParent());
BasicBlock *GBB = BasicBlock::Create(Context, "", G);
// Create g -ref-> f.
- (void)CastInst::CreatePointerCast(&F, Type::getInt8PtrTy(Context), "", GBB);
+ (void)CastInst::CreatePointerCast(&F, PointerType::getUnqual(Context), "",
+ GBB);
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2525,7 +2527,7 @@ TEST(LazyCallGraphTest, AddSplitFunction5) {
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2673,7 +2675,7 @@ TEST(LazyCallGraphTest, AddSplitFunction8) {
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2722,7 +2724,8 @@ TEST(LazyCallGraphTest, AddSplitFunction9) {
F.getAddressSpace(), "g", F.getParent());
BasicBlock *GBB = BasicBlock::Create(Context, "", G);
// Create g -ref-> f2.
- (void)CastInst::CreatePointerCast(&F2, Type::getInt8PtrTy(Context), "", GBB);
+ (void)CastInst::CreatePointerCast(&F2, PointerType::getUnqual(Context), "",
+ GBB);
(void)ReturnInst::Create(Context, GBB);
// Create f -call-> g.
@@ -2769,7 +2772,7 @@ TEST(LazyCallGraphTest, AddSplitFunctions1) {
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2808,11 +2811,12 @@ TEST(LazyCallGraphTest, AddSplitFunctions2) {
F.getAddressSpace(), "g", F.getParent());
BasicBlock *GBB = BasicBlock::Create(Context, "", G);
// Create g -ref-> f.
- (void)CastInst::CreatePointerCast(&F, Type::getInt8PtrTy(Context), "", GBB);
+ (void)CastInst::CreatePointerCast(&F, PointerType::getUnqual(Context), "",
+ GBB);
(void)ReturnInst::Create(Context, GBB);
// Create f -ref-> g.
- (void)CastInst::CreatePointerCast(G, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2857,15 +2861,17 @@ TEST(LazyCallGraphTest, AddSplitFunctions3) {
BasicBlock *G1BB = BasicBlock::Create(Context, "", G1);
BasicBlock *G2BB = BasicBlock::Create(Context, "", G2);
// Create g1 -ref-> g2 and g2 -ref-> g1.
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "", G1BB);
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "", G2BB);
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
+ G1BB);
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
+ G2BB);
(void)ReturnInst::Create(Context, G1BB);
(void)ReturnInst::Create(Context, G2BB);
// Create f -ref-> g1 and f -ref-> g2.
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2911,17 +2917,20 @@ TEST(LazyCallGraphTest, AddSplitFunctions4) {
BasicBlock *G1BB = BasicBlock::Create(Context, "", G1);
BasicBlock *G2BB = BasicBlock::Create(Context, "", G2);
// Create g1 -ref-> g2 and g2 -ref-> g1.
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "", G1BB);
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "", G2BB);
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
+ G1BB);
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
+ G2BB);
// Create g2 -ref-> f.
- (void)CastInst::CreatePointerCast(&F, Type::getInt8PtrTy(Context), "", G2BB);
+ (void)CastInst::CreatePointerCast(&F, PointerType::getUnqual(Context), "",
+ G2BB);
(void)ReturnInst::Create(Context, G1BB);
(void)ReturnInst::Create(Context, G2BB);
// Create f -ref-> g1 and f -ref-> g2.
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -2978,17 +2987,20 @@ TEST(LazyCallGraphTest, AddSplitFunctions5) {
BasicBlock *G1BB = BasicBlock::Create(Context, "", G1);
BasicBlock *G2BB = BasicBlock::Create(Context, "", G2);
// Create g1 -ref-> g2 and g2 -ref-> g1.
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "", G1BB);
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "", G2BB);
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
+ G1BB);
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
+ G2BB);
// Create g2 -ref-> f2.
- (void)CastInst::CreatePointerCast(&F2, Type::getInt8PtrTy(Context), "", G2BB);
+ (void)CastInst::CreatePointerCast(&F2, PointerType::getUnqual(Context), "",
+ G2BB);
(void)ReturnInst::Create(Context, G1BB);
(void)ReturnInst::Create(Context, G2BB);
// Create f -ref-> g1 and f -ref-> g2.
- (void)CastInst::CreatePointerCast(G1, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G1, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
- (void)CastInst::CreatePointerCast(G2, Type::getInt8PtrTy(Context), "",
+ (void)CastInst::CreatePointerCast(G2, PointerType::getUnqual(Context), "",
&*F.getEntryBlock().begin());
EXPECT_FALSE(verifyModule(*M, &errs()));
diff --git a/llvm/unittests/Analysis/MemoryBuiltinsTest.cpp b/llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
index 7fa54a6ce23e12c..ca2a1a609438a0d 100644
--- a/llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
+++ b/llvm/unittests/Analysis/MemoryBuiltinsTest.cpp
@@ -26,7 +26,7 @@ TEST(AllocSize, AllocationBuiltinsTest) {
IntegerType *ArgTy = Type::getInt32Ty(Context);
Function *AllocSizeFn = Function::Create(
- FunctionType::get(Type::getInt8PtrTy(Context), {ArgTy}, false),
+ FunctionType::get(PointerType::getUnqual(Context), {ArgTy}, false),
GlobalValue::ExternalLinkage, "F", &M);
AllocSizeFn->addFnAttr(
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index e883b4291695488..a7b3c5c404ab75a 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -677,7 +677,7 @@ TEST_F(ScalarEvolutionsTest, SCEVZeroExtendExpr) {
Type *I64Ty = Type::getInt64Ty(Context);
Type *I8Ty = Type::getInt8Ty(Context);
- Type *I8PtrTy = Type::getInt8PtrTy(Context);
+ Type *I8PtrTy = PointerType::getUnqual(Context);
Value *Accum = Constant::getNullValue(I8PtrTy);
int Iters = 20;
for (int i = 0; i < Iters; i++) {
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 58aea370e271921..50759d7c61029d8 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5397,7 +5397,7 @@ TEST_F(OpenMPIRBuilderTest, EmitMapperCall) {
GlobalVariable *Mapnames =
OMPBuilder.createOffloadMapnames(Names, ".offload_mapnames");
Value *MapnamesArg = Builder.CreateConstInBoundsGEP2_32(
- ArrayType::get(Type::getInt8PtrTy(Ctx), TotalNbOperand), Mapnames,
+ ArrayType::get(PointerType::getUnqual(Ctx), TotalNbOperand), Mapnames,
/*Idx0=*/0, /*Idx1=*/0);
OMPBuilder.emitMapperCall(Builder.saveIP(), BeginMapperFunc, SrcLocInfo,
@@ -6177,7 +6177,7 @@ TEST_F(OpenMPIRBuilderTest, CreateTaskDepend) {
ASSERT_NE(NumDepsNoAlias, nullptr);
EXPECT_EQ(NumDepsNoAlias->getZExtValue(), 0U);
EXPECT_EQ(TaskAllocCall->getOperand(6),
- ConstantPointerNull::get(Type::getInt8PtrTy(M->getContext())));
+ ConstantPointerNull::get(PointerType::getUnqual(M->getContext())));
EXPECT_FALSE(verifyModule(*M, &errs()));
}
diff --git a/llvm/unittests/FuzzMutate/OperationsTest.cpp b/llvm/unittests/FuzzMutate/OperationsTest.cpp
index e8c84d8cd26798b..be4c75423a89a53 100644
--- a/llvm/unittests/FuzzMutate/OperationsTest.cpp
+++ b/llvm/unittests/FuzzMutate/OperationsTest.cpp
@@ -357,7 +357,7 @@ TEST(OperationsTest, SplitBlockWithPhis) {
TEST(OperationsTest, GEP) {
LLVMContext Ctx;
- Type *Int8PtrTy = Type::getInt8PtrTy(Ctx);
+ Type *Int8PtrTy = PointerType::getUnqual(Ctx);
Type *Int32Ty = Type::getInt32Ty(Ctx);
Module M("M", Ctx);
@@ -405,7 +405,7 @@ TEST(OperationsTest, GEPPointerOperand) {
TEST(OperationsTest, ExtractAndInsertValue) {
LLVMContext Ctx;
- Type *Int8PtrTy = Type::getInt8PtrTy(Ctx);
+ Type *Int8PtrTy = PointerType::getUnqual(Ctx);
Type *Int32Ty = Type::getInt32Ty(Ctx);
Type *Int64Ty = Type::getInt64Ty(Ctx);
diff --git a/llvm/unittests/Linker/LinkModulesTest.cpp b/llvm/unittests/Linker/LinkModulesTest.cpp
index b301e5a9c70290e..182ce73178c1d47 100644
--- a/llvm/unittests/Linker/LinkModulesTest.cpp
+++ b/llvm/unittests/Linker/LinkModulesTest.cpp
@@ -27,8 +27,9 @@ class LinkModuleTest : public testing::Test {
protected:
void SetUp() override {
M.reset(new Module("MyModule", Ctx));
- FunctionType *FTy = FunctionType::get(
- Type::getInt8PtrTy(Ctx), Type::getInt32Ty(Ctx), false /*=isVarArg*/);
+ FunctionType *FTy =
+ FunctionType::get(PointerType::getUnqual(Ctx), Type::getInt32Ty(Ctx),
+ false /*=isVarArg*/);
F = Function::Create(FTy, Function::ExternalLinkage, "ba_func", M.get());
F->setCallingConv(CallingConv::C);
@@ -37,7 +38,7 @@ class LinkModuleTest : public testing::Test {
SwitchCase2BB = BasicBlock::Create(Ctx, "switch.case.2", F);
ExitBB = BasicBlock::Create(Ctx, "exit", F);
- AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3);
+ AT = ArrayType::get(PointerType::getUnqual(Ctx), 3);
GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/,
GlobalValue::InternalLinkage, nullptr,"switch.bas");
@@ -51,7 +52,8 @@ class LinkModuleTest : public testing::Test {
Init.push_back(SwitchCase2BA);
ConstantInt *One = ConstantInt::get(Type::getInt32Ty(Ctx), 1);
- Constant *OnePtr = ConstantExpr::getIntToPtr(One, Type::getInt8PtrTy(Ctx));
+ Constant *OnePtr =
+ ConstantExpr::getIntToPtr(One, PointerType::getUnqual(Ctx));
Init.push_back(OnePtr);
GV->setInitializer(ConstantArray::get(AT, Init));
@@ -93,7 +95,7 @@ TEST_F(LinkModuleTest, BlockAddress) {
Builder.CreateBr(ExitBB);
Builder.SetInsertPoint(ExitBB);
- Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx)));
+ Builder.CreateRet(ConstantPointerNull::get(PointerType::getUnqual(Ctx)));
Module *LinkedModule = new Module("MyModuleLinked", Ctx);
Ctx.setDiagnosticHandlerCallBack(expectNoDiags);
@@ -108,7 +110,7 @@ TEST_F(LinkModuleTest, BlockAddress) {
// i8* blockaddress(@ba_func, %switch.case.2),
// i8* inttoptr (i32 1 to i8*)]
- ArrayType *AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3);
+ ArrayType *AT = ArrayType::get(PointerType::getUnqual(Ctx), 3);
EXPECT_EQ(AT, Init->getType());
Value *Elem = Init->getOperand(0);
@@ -132,7 +134,7 @@ static Module *getExternal(LLVMContext &Ctx, StringRef FuncName) {
// Create a module with an empty externally-linked function
Module *M = new Module("ExternalModule", Ctx);
FunctionType *FTy = FunctionType::get(
- Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx), false /*=isVarArgs*/);
+ Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx), false /*=isVarArgs*/);
Function *F =
Function::Create(FTy, Function::ExternalLinkage, FuncName, M);
@@ -147,7 +149,7 @@ static Module *getExternal(LLVMContext &Ctx, StringRef FuncName) {
static Module *getInternal(LLVMContext &Ctx) {
Module *InternalM = new Module("InternalModule", Ctx);
FunctionType *FTy = FunctionType::get(
- Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx), false /*=isVarArgs*/);
+ Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx), false /*=isVarArgs*/);
Function *F =
Function::Create(FTy, Function::InternalLinkage, "bar", InternalM);
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 2a7e276ac62d80f..6ce76ed049600f0 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1093,7 +1093,7 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF,
Size = SE.getElementSize(Inst);
} else {
auto *SizeTy =
- SE.getEffectiveSCEVType(PointerType::getInt8PtrTy(SE.getContext()));
+ SE.getEffectiveSCEVType(Type::getUnqual(SE.getContext()));
Size = SE.getConstant(SizeTy, 8);
}
>From 19ac42f1932f600382de0f37e023f7003fa7101c Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at igalia.com>
Date: Tue, 7 Nov 2023 08:50:58 +0100
Subject: [PATCH 2/3] Fix OMPIRBuilder.cpp
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 73 +++++------------------
1 file changed, 16 insertions(+), 57 deletions(-)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 3b73bb0a9fa4c0a..eb6c120b2a6dcbd 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1428,63 +1428,22 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
LLVM_DEBUG(dbgs() << "After body codegen: " << *OuterFn << "\n");
OutlineInfo OI;
- OI.PostOutlineCB = [=](Function &OutlinedFn) {
- // Add some known attributes.
- OutlinedFn.addParamAttr(0, Attribute::NoAlias);
- OutlinedFn.addParamAttr(1, Attribute::NoAlias);
- OutlinedFn.addFnAttr(Attribute::NoUnwind);
- OutlinedFn.addFnAttr(Attribute::NoRecurse);
-
- assert(OutlinedFn.arg_size() >= 2 &&
- "Expected at least tid and bounded tid as arguments");
- unsigned NumCapturedVars =
- OutlinedFn.arg_size() - /* tid & bounded tid */ 2;
-
- CallInst *CI = cast<CallInst>(OutlinedFn.user_back());
- CI->getParent()->setName("omp_parallel");
- Builder.SetInsertPoint(CI);
-
- // Build call __kmpc_fork_call[_if](Ident, n, microtask, var1, .., varn);
- Value *ForkCallArgs[] = {
- Ident, Builder.getInt32(NumCapturedVars),
- Builder.CreateBitCast(&OutlinedFn, ParallelTaskPtr)};
-
- SmallVector<Value *, 16> RealArgs;
- RealArgs.append(std::begin(ForkCallArgs), std::end(ForkCallArgs));
- if (IfCondition) {
- Value *Cond = Builder.CreateSExtOrTrunc(IfCondition,
- Type::getInt32Ty(M.getContext()));
- RealArgs.push_back(Cond);
- }
- RealArgs.append(CI->arg_begin() + /* tid & bound tid */ 2, CI->arg_end());
-
- // __kmpc_fork_call_if always expects a void ptr as the last argument
- // If there are no arguments, pass a null pointer.
- auto PtrTy = PointerType::getUnqual(M.getContext());
- if (IfCondition && NumCapturedVars == 0) {
- llvm::Value *Void = ConstantPointerNull::get(PtrTy);
- RealArgs.push_back(Void);
- }
- if (IfCondition && RealArgs.back()->getType() != PtrTy)
- RealArgs.back() = Builder.CreateBitCast(RealArgs.back(), PtrTy);
-
- Builder.CreateCall(RTLFn, RealArgs);
-
- LLVM_DEBUG(dbgs() << "With fork_call placed: "
- << *Builder.GetInsertBlock()->getParent() << "\n");
-
- InsertPointTy ExitIP(PRegExitBB, PRegExitBB->end());
-
- // Initialize the local TID stack location with the argument value.
- Builder.SetInsertPoint(PrivTID);
- Function::arg_iterator OutlinedAI = OutlinedFn.arg_begin();
- Builder.CreateStore(Builder.CreateLoad(Int32, OutlinedAI), PrivTIDAddr);
-
- CI->eraseFromParent();
-
- for (Instruction *I : ToBeDeleted)
- I->eraseFromParent();
- };
+ if (Config.isTargetDevice()) {
+ // Generate OpenMP target specific runtime call
+ OI.PostOutlineCB = [=, ToBeDeletedVec =
+ std::move(ToBeDeleted)](Function &OutlinedFn) {
+ targetParallelCallback(this, OutlinedFn, OuterFn, OuterAllocaBlock, Ident,
+ IfCondition, NumThreads, PrivTID, PrivTIDAddr,
+ ThreadID, ToBeDeletedVec);
+ };
+ } else {
+ // Generate OpenMP host runtime call
+ OI.PostOutlineCB = [=, ToBeDeletedVec =
+ std::move(ToBeDeleted)](Function &OutlinedFn) {
+ hostParallelCallback(this, OutlinedFn, OuterFn, Ident, IfCondition,
+ PrivTID, PrivTIDAddr, ToBeDeletedVec);
+ };
+ }
// Adjust the finalization stack, verify the adjustment, and call the
// finalize function a last time to finalize values between the pre-fini
>From 28b284c6be2386b4089105373f587314183d6004 Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at igalia.com>
Date: Tue, 7 Nov 2023 08:52:13 +0100
Subject: [PATCH 3/3] Fix ScopDetection.cpp
---
polly/lib/Analysis/ScopDetection.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 6ce76ed049600f0..db1f844950063fd 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1093,7 +1093,7 @@ bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF,
Size = SE.getElementSize(Inst);
} else {
auto *SizeTy =
- SE.getEffectiveSCEVType(Type::getUnqual(SE.getContext()));
+ SE.getEffectiveSCEVType(PointerType::getUnqual(SE.getContext()));
Size = SE.getConstant(SizeTy, 8);
}
More information about the llvm-commits
mailing list