13 changes: 4 additions & 9 deletions llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,11 +2263,11 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,

if (DestVolatile) {
Type *Int32Ty = Type::getInt32Ty(Ctx);
Type *Int32PtrTy = Type::getInt32PtrTy(Ctx);
Type *PtrTy = PointerType::get(Ctx, 0);
Type *VoidTy = Type::getVoidTy(Ctx);
Module *M = Func->getParent();
FunctionCallee Fn = M->getOrInsertFunction(
HexagonVolatileMemcpyName, VoidTy, Int32PtrTy, Int32PtrTy, Int32Ty);
HexagonVolatileMemcpyName, VoidTy, PtrTy, PtrTy, Int32Ty);

const SCEV *OneS = SE->getConstant(Int32Ty, 1);
const SCEV *BECount32 = SE->getTruncateOrZeroExtend(BECount, Int32Ty);
Expand All @@ -2278,13 +2278,8 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
if (Value *Simp = simplifyInstruction(In, {*DL, TLI, DT}))
NumWords = Simp;

Value *Op0 = (StoreBasePtr->getType() == Int32PtrTy)
? StoreBasePtr
: CondBuilder.CreateBitCast(StoreBasePtr, Int32PtrTy);
Value *Op1 = (LoadBasePtr->getType() == Int32PtrTy)
? LoadBasePtr
: CondBuilder.CreateBitCast(LoadBasePtr, Int32PtrTy);
NewCall = CondBuilder.CreateCall(Fn, {Op0, Op1, NumWords});
NewCall = CondBuilder.CreateCall(Fn,
{StoreBasePtr, LoadBasePtr, NumWords});
} else {
NewCall = CondBuilder.CreateMemMove(
StoreBasePtr, SI->getAlign(), LoadBasePtr, LI->getAlign(), NumBytes);
Expand Down
45 changes: 22 additions & 23 deletions llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ static Type *getAddrIntType(Module *M) {
}

// Returns an integer pointer type for the target architecture's address space.
// i32* for wasm32 and i64* for wasm64.
// i32* for wasm32 and i64* for wasm64. With opaque pointers this is just a ptr
// in address space zero.
static Type *getAddrPtrType(Module *M) {
return Type::getIntNPtrTy(M->getContext(),
M->getDataLayout().getPointerSizeInBits());
return PointerType::getUnqual(M->getContext());
}

// Returns an integer whose type is the integer type for the target's address
Expand All @@ -495,7 +495,7 @@ WebAssemblyLowerEmscriptenEHSjLj::getFindMatchingCatch(Module &M,
unsigned NumClauses) {
if (FindMatchingCatches.count(NumClauses))
return FindMatchingCatches[NumClauses];
PointerType *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
PointerType *Int8PtrTy = PointerType::getUnqual(M.getContext());
SmallVector<Type *, 16> Args(NumClauses, Int8PtrTy);
FunctionType *FTy = FunctionType::get(Int8PtrTy, Args, false);
Function *F = getEmscriptenFunction(
Expand Down Expand Up @@ -831,8 +831,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::replaceLongjmpWith(Function *LongjmpF,
Env =
IRB.CreatePtrToInt(CI->getArgOperand(0), getAddrIntType(M), "env");
else // WasmLongjmpF
Env =
IRB.CreateBitCast(CI->getArgOperand(0), IRB.getInt8PtrTy(), "env");
Env = IRB.CreateBitCast(CI->getArgOperand(0), IRB.getPtrTy(), "env");
IRB.CreateCall(NewF, {Env, CI->getArgOperand(1)});
ToErase.push_back(CI);
}
Expand Down Expand Up @@ -945,13 +944,13 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runOnModule(Module &M) {
if (EnableEmEH) {
// Register __resumeException function
FunctionType *ResumeFTy =
FunctionType::get(IRB.getVoidTy(), IRB.getInt8PtrTy(), false);
FunctionType::get(IRB.getVoidTy(), IRB.getPtrTy(), false);
ResumeF = getEmscriptenFunction(ResumeFTy, "__resumeException", &M);
ResumeF->addFnAttr(Attribute::NoReturn);

// Register llvm_eh_typeid_for function
FunctionType *EHTypeIDTy =
FunctionType::get(IRB.getInt32Ty(), IRB.getInt8PtrTy(), false);
FunctionType::get(IRB.getInt32Ty(), IRB.getPtrTy(), false);
EHTypeIDF = getEmscriptenFunction(EHTypeIDTy, "llvm_eh_typeid_for", &M);
}

Expand Down Expand Up @@ -995,36 +994,36 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runOnModule(Module &M) {
EmLongjmpF = getEmscriptenFunction(FTy, "emscripten_longjmp", &M);
EmLongjmpF->addFnAttr(Attribute::NoReturn);
} else { // EnableWasmSjLj
Type *Int8PtrTy = IRB.getPtrTy();
// Register __wasm_longjmp function, which calls __builtin_wasm_longjmp.
FunctionType *FTy = FunctionType::get(
IRB.getVoidTy(), {IRB.getInt8PtrTy(), IRB.getInt32Ty()}, false);
IRB.getVoidTy(), {Int8PtrTy, IRB.getInt32Ty()}, false);
WasmLongjmpF = getEmscriptenFunction(FTy, "__wasm_longjmp", &M);
WasmLongjmpF->addFnAttr(Attribute::NoReturn);
}

if (SetjmpF) {
Type *Int8PtrTy = IRB.getPtrTy();
Type *Int32PtrTy = IRB.getPtrTy();
Type *Int32Ty = IRB.getInt32Ty();
// Register saveSetjmp function
FunctionType *SetjmpFTy = SetjmpF->getFunctionType();
FunctionType *FTy =
FunctionType::get(Type::getInt32PtrTy(C),
{SetjmpFTy->getParamType(0), IRB.getInt32Ty(),
Type::getInt32PtrTy(C), IRB.getInt32Ty()},
false);
FunctionType *FTy = FunctionType::get(
Int32PtrTy,
{SetjmpFTy->getParamType(0), Int32Ty, Int32PtrTy, Int32Ty}, false);
SaveSetjmpF = getEmscriptenFunction(FTy, "saveSetjmp", &M);

// Register testSetjmp function
FTy = FunctionType::get(
IRB.getInt32Ty(),
{getAddrIntType(&M), Type::getInt32PtrTy(C), IRB.getInt32Ty()},
false);
FTy = FunctionType::get(Int32Ty,
{getAddrIntType(&M), Int32PtrTy, Int32Ty}, false);
TestSetjmpF = getEmscriptenFunction(FTy, "testSetjmp", &M);

// wasm.catch() will be lowered down to wasm 'catch' instruction in
// instruction selection.
CatchF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_catch);
// Type for struct __WasmLongjmpArgs
LongjmpArgsTy = StructType::get(IRB.getInt8PtrTy(), // env
IRB.getInt32Ty() // val
LongjmpArgsTy = StructType::get(Int8PtrTy, // env
Int32Ty // val
);
}
}
Expand Down Expand Up @@ -1426,7 +1425,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
// saveSetjmp and testSetjmp calls have the correct arguments.
SSAUpdater SetjmpTableSSA;
SSAUpdater SetjmpTableSizeSSA;
SetjmpTableSSA.Initialize(Type::getInt32PtrTy(C), "setjmpTable");
SetjmpTableSSA.Initialize(PointerType::get(C, 0), "setjmpTable");
SetjmpTableSizeSSA.Initialize(Type::getInt32Ty(C), "setjmpTableSize");
for (Instruction *I : SetjmpTableInsts)
SetjmpTableSSA.AddAvailableValue(I->getParent(), I);
Expand Down Expand Up @@ -1680,7 +1679,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
FunctionType::get(IRB.getInt32Ty(), /* isVarArg */ true);
Value *PersF = M.getOrInsertFunction(PersName, PersType).getCallee();
F.setPersonalityFn(
cast<Constant>(IRB.CreateBitCast(PersF, IRB.getInt8PtrTy())));
cast<Constant>(IRB.CreateBitCast(PersF, IRB.getPtrTy())));
}

// Use the entry BB's debugloc as a fallback
Expand Down Expand Up @@ -1733,7 +1732,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
Value *ValField =
IRB.CreateConstGEP2_32(LongjmpArgsTy, LongjmpArgs, 0, 1, "val_gep");
// void *env = __wasm_longjmp_args.env;
Instruction *Env = IRB.CreateLoad(IRB.getInt8PtrTy(), EnvField, "env");
Instruction *Env = IRB.CreateLoad(IRB.getPtrTy(), EnvField, "env");
// int val = __wasm_longjmp_args.val;
Instruction *Val = IRB.CreateLoad(IRB.getInt32Ty(), ValField, "val");

Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18585,11 +18585,9 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
// Get the Thread Pointer, which is %fs:__tls_array (32-bit) or
// %gs:0x58 (64-bit). On MinGW, __tls_array is not available, so directly
// use its literal value of 0x2C.
Value *Ptr = Constant::getNullValue(Subtarget.is64Bit()
? Type::getInt8PtrTy(*DAG.getContext(),
256)
: Type::getInt32PtrTy(*DAG.getContext(),
257));
Value *Ptr = Constant::getNullValue(
Subtarget.is64Bit() ? PointerType::get(*DAG.getContext(), 256)
: PointerType::get(*DAG.getContext(), 257));

SDValue TlsArray = Subtarget.is64Bit()
? DAG.getIntPtrConstant(0x58, dl)
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ static Value *constructPointer(Type *ResTy, Type *PtrElemTy, Value *Ptr,

// If an offset is left we use byte-wise adjustment.
if (IntOffset != 0) {
Ptr = IRB.CreateBitCast(Ptr, IRB.getInt8PtrTy());
Ptr = IRB.CreateGEP(IRB.getInt8Ty(), Ptr, IRB.getInt(IntOffset),
GEPName + ".b" + Twine(IntOffset.getZExtValue()));
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CrossDSOCFI::buildCFICheck(Module &M) {
LLVMContext &Ctx = M.getContext();
FunctionCallee C = M.getOrInsertFunction(
"__cfi_check", Type::getVoidTy(Ctx), Type::getInt64Ty(Ctx),
Type::getInt8PtrTy(Ctx), Type::getInt8PtrTy(Ctx));
PointerType::getUnqual(Ctx), PointerType::getUnqual(Ctx));
Function *F = cast<Function>(C.getCallee());
// Take over the existing function. The frontend emits a weak stub so that the
// linker knows about the symbol; this pass replaces the function body.
Expand All @@ -110,9 +110,9 @@ void CrossDSOCFI::buildCFICheck(Module &M) {

BasicBlock *TrapBB = BasicBlock::Create(Ctx, "fail", F);
IRBuilder<> IRBFail(TrapBB);
FunctionCallee CFICheckFailFn =
M.getOrInsertFunction("__cfi_check_fail", Type::getVoidTy(Ctx),
Type::getInt8PtrTy(Ctx), Type::getInt8PtrTy(Ctx));
FunctionCallee CFICheckFailFn = M.getOrInsertFunction(
"__cfi_check_fail", Type::getVoidTy(Ctx), PointerType::getUnqual(Ctx),
PointerType::getUnqual(Ctx));
IRBFail.CreateCall(CFICheckFailFn, {&CFICheckFailData, &Addr});
IRBFail.CreateBr(ExitBB);

Expand Down
15 changes: 6 additions & 9 deletions llvm/lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,10 +1905,8 @@ static void RemovePreallocated(Function *F) {
Builder.SetInsertPoint(InsertBefore);
auto *Alloca =
Builder.CreateAlloca(ArgType, AddressSpace, nullptr, "paarg");
auto *BitCast = Builder.CreateBitCast(
Alloca, Type::getInt8PtrTy(M->getContext()), UseCall->getName());
ArgAllocas[AllocArgIndex] = BitCast;
AllocaReplacement = BitCast;
ArgAllocas[AllocArgIndex] = Alloca;
AllocaReplacement = Alloca;
}

UseCall->replaceAllUsesWith(AllocaReplacement);
Expand Down Expand Up @@ -2117,19 +2115,18 @@ static void setUsedInitializer(GlobalVariable &V,
const auto *VEPT = cast<PointerType>(VAT->getArrayElementType());

// Type of pointer to the array of pointers.
PointerType *Int8PtrTy =
Type::getInt8PtrTy(V.getContext(), VEPT->getAddressSpace());
PointerType *PtrTy =
PointerType::get(V.getContext(), VEPT->getAddressSpace());

SmallVector<Constant *, 8> UsedArray;
for (GlobalValue *GV : Init) {
Constant *Cast =
ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, Int8PtrTy);
Constant *Cast = ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, PtrTy);
UsedArray.push_back(Cast);
}

// Sort to get deterministic order.
array_pod_sort(UsedArray.begin(), UsedArray.end(), compareNames);
ArrayType *ATy = ArrayType::get(Int8PtrTy, UsedArray.size());
ArrayType *ATy = ArrayType::get(PtrTy, UsedArray.size());

Module *M = V.getParent();
V.removeFromParent();
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/IPO/LowerTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ class LowerTypeTestsModule {

IntegerType *Int1Ty = Type::getInt1Ty(M.getContext());
IntegerType *Int8Ty = Type::getInt8Ty(M.getContext());
PointerType *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
PointerType *Int8PtrTy = PointerType::getUnqual(M.getContext());
ArrayType *Int8Arr0Ty = ArrayType::get(Type::getInt8Ty(M.getContext()), 0);
IntegerType *Int32Ty = Type::getInt32Ty(M.getContext());
PointerType *Int32PtrTy = PointerType::getUnqual(Int32Ty);
PointerType *Int32PtrTy = PointerType::getUnqual(M.getContext());
IntegerType *Int64Ty = Type::getInt64Ty(M.getContext());
IntegerType *IntPtrTy = M.getDataLayout().getIntPtrType(M.getContext(), 0);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4381,7 +4381,7 @@ struct AAKernelInfoFunction : AAKernelInfo {

// Create local storage for the work function pointer.
const DataLayout &DL = M.getDataLayout();
Type *VoidPtrTy = Type::getInt8PtrTy(Ctx);
Type *VoidPtrTy = PointerType::getUnqual(Ctx);
Instruction *WorkFnAI =
new AllocaInst(VoidPtrTy, DL.getAllocaAddrSpace(), nullptr,
"worker.work_fn.addr", &Kernel->getEntryBlock().front());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ struct DevirtModule {
: M(M), AARGetter(AARGetter), LookupDomTree(LookupDomTree),
ExportSummary(ExportSummary), ImportSummary(ImportSummary),
Int8Ty(Type::getInt8Ty(M.getContext())),
Int8PtrTy(Type::getInt8PtrTy(M.getContext())),
Int8PtrTy(PointerType::getUnqual(M.getContext())),
Int32Ty(Type::getInt32Ty(M.getContext())),
Int64Ty(Type::getInt64Ty(M.getContext())),
IntPtrTy(M.getDataLayout().getIntPtrType(M.getContext(), 0)),
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ static Value *rewriteGEPAsOffset(Type *ElemTy, Value *Start, Value *Base,
}
}

PointerType *PtrTy =
ElemTy->getPointerTo(Start->getType()->getPointerAddressSpace());
PointerType *PtrTy = PointerType::get(
Base->getContext(), Start->getType()->getPointerAddressSpace());
for (Value *Val : Explored) {
if (Val == Base)
continue;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
auto &Ctx = InsertAt->getContext();
auto *SI = new StoreInst(ConstantInt::getTrue(Ctx),
PoisonValue::get(Type::getInt1PtrTy(Ctx)),
PoisonValue::get(PointerType::getUnqual(Ctx)),
/*isVolatile*/ false, Align(1));
InsertNewInstBefore(SI, *InsertAt);
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,7 @@ struct VarArgAArch64Helper : public VarArgHelper {
Value *SaveAreaPtrPtr = IRB.CreateIntToPtr(
IRB.CreateAdd(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
ConstantInt::get(MS.IntptrTy, offset)),
Type::getInt64PtrTy(*MS.C));
PointerType::get(*MS.C, 0));
return IRB.CreateLoad(Type::getInt64Ty(*MS.C), SaveAreaPtrPtr);
}

Expand All @@ -5211,7 +5211,7 @@ struct VarArgAArch64Helper : public VarArgHelper {
Value *SaveAreaPtr = IRB.CreateIntToPtr(
IRB.CreateAdd(IRB.CreatePtrToInt(VAListTag, MS.IntptrTy),
ConstantInt::get(MS.IntptrTy, offset)),
Type::getInt32PtrTy(*MS.C));
PointerType::get(*MS.C, 0));
Value *SaveArea32 = IRB.CreateLoad(IRB.getInt32Ty(), SaveAreaPtr);
return IRB.CreateSExt(SaveArea32, MS.IntptrTy);
}
Expand Down
76 changes: 34 additions & 42 deletions llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void ThreadSanitizer::initialize(Module &M, const TargetLibraryInfo &TLI) {
Attr = Attr.addFnAttribute(Ctx, Attribute::NoUnwind);
// Initialize the callbacks.
TsanFuncEntry = M.getOrInsertFunction("__tsan_func_entry", Attr,
IRB.getVoidTy(), IRB.getInt8PtrTy());
IRB.getVoidTy(), IRB.getPtrTy());
TsanFuncExit =
M.getOrInsertFunction("__tsan_func_exit", Attr, IRB.getVoidTy());
TsanIgnoreBegin = M.getOrInsertFunction("__tsan_ignore_thread_begin", Attr,
Expand All @@ -220,49 +220,49 @@ void ThreadSanitizer::initialize(Module &M, const TargetLibraryInfo &TLI) {
std::string BitSizeStr = utostr(BitSize);
SmallString<32> ReadName("__tsan_read" + ByteSizeStr);
TsanRead[i] = M.getOrInsertFunction(ReadName, Attr, IRB.getVoidTy(),
IRB.getInt8PtrTy());
IRB.getPtrTy());

SmallString<32> WriteName("__tsan_write" + ByteSizeStr);
TsanWrite[i] = M.getOrInsertFunction(WriteName, Attr, IRB.getVoidTy(),
IRB.getInt8PtrTy());
IRB.getPtrTy());

SmallString<64> UnalignedReadName("__tsan_unaligned_read" + ByteSizeStr);
TsanUnalignedRead[i] = M.getOrInsertFunction(
UnalignedReadName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
UnalignedReadName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> UnalignedWriteName("__tsan_unaligned_write" + ByteSizeStr);
TsanUnalignedWrite[i] = M.getOrInsertFunction(
UnalignedWriteName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
UnalignedWriteName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> VolatileReadName("__tsan_volatile_read" + ByteSizeStr);
TsanVolatileRead[i] = M.getOrInsertFunction(
VolatileReadName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
VolatileReadName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> VolatileWriteName("__tsan_volatile_write" + ByteSizeStr);
TsanVolatileWrite[i] = M.getOrInsertFunction(
VolatileWriteName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
VolatileWriteName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> UnalignedVolatileReadName("__tsan_unaligned_volatile_read" +
ByteSizeStr);
TsanUnalignedVolatileRead[i] = M.getOrInsertFunction(
UnalignedVolatileReadName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
UnalignedVolatileReadName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> UnalignedVolatileWriteName(
"__tsan_unaligned_volatile_write" + ByteSizeStr);
TsanUnalignedVolatileWrite[i] = M.getOrInsertFunction(
UnalignedVolatileWriteName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
UnalignedVolatileWriteName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> CompoundRWName("__tsan_read_write" + ByteSizeStr);
TsanCompoundRW[i] = M.getOrInsertFunction(
CompoundRWName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
CompoundRWName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

SmallString<64> UnalignedCompoundRWName("__tsan_unaligned_read_write" +
ByteSizeStr);
TsanUnalignedCompoundRW[i] = M.getOrInsertFunction(
UnalignedCompoundRWName, Attr, IRB.getVoidTy(), IRB.getInt8PtrTy());
UnalignedCompoundRWName, Attr, IRB.getVoidTy(), IRB.getPtrTy());

Type *Ty = Type::getIntNTy(Ctx, BitSize);
Type *PtrTy = Ty->getPointerTo();
Type *PtrTy = PointerType::get(Ctx, 0);
SmallString<32> AtomicLoadName("__tsan_atomic" + BitSizeStr + "_load");
TsanAtomicLoad[i] =
M.getOrInsertFunction(AtomicLoadName,
Expand Down Expand Up @@ -318,9 +318,9 @@ void ThreadSanitizer::initialize(Module &M, const TargetLibraryInfo &TLI) {
}
TsanVptrUpdate =
M.getOrInsertFunction("__tsan_vptr_update", Attr, IRB.getVoidTy(),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy());
IRB.getPtrTy(), IRB.getPtrTy());
TsanVptrLoad = M.getOrInsertFunction("__tsan_vptr_read", Attr,
IRB.getVoidTy(), IRB.getInt8PtrTy());
IRB.getVoidTy(), IRB.getPtrTy());
TsanAtomicThreadFence = M.getOrInsertFunction(
"__tsan_atomic_thread_fence",
TLI.getAttrList(&Ctx, {0}, /*Signed=*/true, /*Ret=*/false, Attr),
Expand All @@ -332,15 +332,15 @@ void ThreadSanitizer::initialize(Module &M, const TargetLibraryInfo &TLI) {
IRB.getVoidTy(), OrdTy);

MemmoveFn =
M.getOrInsertFunction("__tsan_memmove", Attr, IRB.getInt8PtrTy(),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy);
M.getOrInsertFunction("__tsan_memmove", Attr, IRB.getPtrTy(),
IRB.getPtrTy(), IRB.getPtrTy(), IntptrTy);
MemcpyFn =
M.getOrInsertFunction("__tsan_memcpy", Attr, IRB.getInt8PtrTy(),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy);
M.getOrInsertFunction("__tsan_memcpy", Attr, IRB.getPtrTy(),
IRB.getPtrTy(), IRB.getPtrTy(), IntptrTy);
MemsetFn = M.getOrInsertFunction(
"__tsan_memset",
TLI.getAttrList(&Ctx, {1}, /*Signed=*/true, /*Ret=*/false, Attr),
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt32Ty(), IntptrTy);
IRB.getPtrTy(), IRB.getPtrTy(), IRB.getInt32Ty(), IntptrTy);
}

static bool isVtableAccess(Instruction *I) {
Expand Down Expand Up @@ -613,17 +613,14 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
StoredValue = IRB.CreateExtractElement(
StoredValue, ConstantInt::get(IRB.getInt32Ty(), 0));
if (StoredValue->getType()->isIntegerTy())
StoredValue = IRB.CreateIntToPtr(StoredValue, IRB.getInt8PtrTy());
StoredValue = IRB.CreateIntToPtr(StoredValue, IRB.getPtrTy());
// Call TsanVptrUpdate.
IRB.CreateCall(TsanVptrUpdate,
{IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
IRB.CreatePointerCast(StoredValue, IRB.getInt8PtrTy())});
IRB.CreateCall(TsanVptrUpdate, {Addr, StoredValue});
NumInstrumentedVtableWrites++;
return true;
}
if (!IsWrite && isVtableAccess(II.Inst)) {
IRB.CreateCall(TsanVptrLoad,
IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()));
IRB.CreateCall(TsanVptrLoad, Addr);
NumInstrumentedVtableReads++;
return true;
}
Expand Down Expand Up @@ -655,7 +652,7 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
else
OnAccessFunc = IsWrite ? TsanUnalignedWrite[Idx] : TsanUnalignedRead[Idx];
}
IRB.CreateCall(OnAccessFunc, IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()));
IRB.CreateCall(OnAccessFunc, Addr);
if (IsCompoundRW || IsWrite)
NumInstrumentedWrites++;
if (IsCompoundRW || !IsWrite)
Expand Down Expand Up @@ -691,17 +688,19 @@ static ConstantInt *createOrdering(IRBuilder<> *IRB, AtomicOrdering ord) {
bool ThreadSanitizer::instrumentMemIntrinsic(Instruction *I) {
InstrumentationIRBuilder IRB(I);
if (MemSetInst *M = dyn_cast<MemSetInst>(I)) {
Value *Cast1 = IRB.CreateIntCast(M->getArgOperand(1), IRB.getInt32Ty(), false);
Value *Cast2 = IRB.CreateIntCast(M->getArgOperand(2), IntptrTy, false);
IRB.CreateCall(
MemsetFn,
{IRB.CreatePointerCast(M->getArgOperand(0), IRB.getInt8PtrTy()),
IRB.CreateIntCast(M->getArgOperand(1), IRB.getInt32Ty(), false),
IRB.CreateIntCast(M->getArgOperand(2), IntptrTy, false)});
{M->getArgOperand(0),
Cast1,
Cast2});
I->eraseFromParent();
} else if (MemTransferInst *M = dyn_cast<MemTransferInst>(I)) {
IRB.CreateCall(
isa<MemCpyInst>(M) ? MemcpyFn : MemmoveFn,
{IRB.CreatePointerCast(M->getArgOperand(0), IRB.getInt8PtrTy()),
IRB.CreatePointerCast(M->getArgOperand(1), IRB.getInt8PtrTy()),
{M->getArgOperand(0),
M->getArgOperand(1),
IRB.CreateIntCast(M->getArgOperand(2), IntptrTy, false)});
I->eraseFromParent();
}
Expand All @@ -724,11 +723,7 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
int Idx = getMemoryAccessFuncIndex(OrigTy, Addr, DL);
if (Idx < 0)
return false;
const unsigned ByteSize = 1U << Idx;
const unsigned BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
Value *Args[] = {Addr,
createOrdering(&IRB, LI->getOrdering())};
Value *C = IRB.CreateCall(TsanAtomicLoad[Idx], Args);
Value *Cast = IRB.CreateBitOrPointerCast(C, OrigTy);
Expand All @@ -742,8 +737,7 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
const unsigned ByteSize = 1U << Idx;
const unsigned BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
Value *Args[] = {Addr,
IRB.CreateBitOrPointerCast(SI->getValueOperand(), Ty),
createOrdering(&IRB, SI->getOrdering())};
CallInst *C = CallInst::Create(TsanAtomicStore[Idx], Args);
Expand All @@ -760,8 +754,7 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
const unsigned ByteSize = 1U << Idx;
const unsigned BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
Value *Args[] = {Addr,
IRB.CreateIntCast(RMWI->getValOperand(), Ty, false),
createOrdering(&IRB, RMWI->getOrdering())};
CallInst *C = CallInst::Create(F, Args);
Expand All @@ -775,12 +768,11 @@ bool ThreadSanitizer::instrumentAtomic(Instruction *I, const DataLayout &DL) {
const unsigned ByteSize = 1U << Idx;
const unsigned BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
Value *CmpOperand =
IRB.CreateBitOrPointerCast(CASI->getCompareOperand(), Ty);
Value *NewOperand =
IRB.CreateBitOrPointerCast(CASI->getNewValOperand(), Ty);
Value *Args[] = {IRB.CreatePointerCast(Addr, PtrTy),
Value *Args[] = {Addr,
CmpOperand,
NewOperand,
createOrdering(&IRB, CASI->getSuccessOrdering()),
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
if (IsNullOrUndef(CI->getArgOperand(0))) {
Changed = true;
new StoreInst(ConstantInt::getTrue(CI->getContext()),
PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
PoisonValue::get(PointerType::getUnqual(CI->getContext())),
CI);
Value *NewValue = PoisonValue::get(CI->getType());
LLVM_DEBUG(
dbgs() << "A null pointer-to-weak-pointer is undefined behavior."
Expand All @@ -952,7 +953,8 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
IsNullOrUndef(CI->getArgOperand(1))) {
Changed = true;
new StoreInst(ConstantInt::getTrue(CI->getContext()),
PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
PoisonValue::get(PointerType::getUnqual(CI->getContext())),
CI);

Value *NewValue = PoisonValue::get(CI->getType());
LLVM_DEBUG(
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/GVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,12 +1998,12 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
if (ConstantInt *Cond = dyn_cast<ConstantInt>(V)) {
if (Cond->isZero()) {
Type *Int8Ty = Type::getInt8Ty(V->getContext());
Type *PtrTy = PointerType::get(V->getContext(), 0);
// Insert a new store to null instruction before the load to indicate that
// this code is not reachable. FIXME: We could insert unreachable
// instruction directly because we can modify the CFG.
auto *NewS = new StoreInst(PoisonValue::get(Int8Ty),
Constant::getNullValue(Int8Ty->getPointerTo()),
IntrinsicI);
Constant::getNullValue(PtrTy), IntrinsicI);
if (MSSAU) {
const MemoryUseOrDef *FirstNonDom = nullptr;
const auto *AL =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void insertCall(Function &CurFn, StringRef Func,
Triple TargetTriple(M.getTargetTriple());
if (TargetTriple.isOSAIX() && Func == "__mcount") {
Type *SizeTy = M.getDataLayout().getIntPtrType(C);
Type *SizePtrTy = SizeTy->getPointerTo();
Type *SizePtrTy = PointerType::getUnqual(C);
GlobalVariable *GV = new GlobalVariable(M, SizeTy, /*isConstant=*/false,
GlobalValue::InternalLinkage,
ConstantInt::get(SizeTy, 0));
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,9 @@ bool Vectorizer::vectorizeChain(Chain &C) {

// Chain is in offset order, so C[0] is the instr with the lowest offset,
// i.e. the root of the vector.
Value *Bitcast = Builder.CreateBitCast(
getLoadStorePointerOperand(C[0].Inst), VecTy->getPointerTo(AS));
VecInst = Builder.CreateAlignedLoad(VecTy, Bitcast, Alignment);
VecInst = Builder.CreateAlignedLoad(VecTy,
getLoadStorePointerOperand(C[0].Inst),
Alignment);

unsigned VecIdx = 0;
for (const ChainElem &E : C) {
Expand Down Expand Up @@ -976,8 +976,7 @@ bool Vectorizer::vectorizeChain(Chain &C) {
// i.e. the root of the vector.
VecInst = Builder.CreateAlignedStore(
Vec,
Builder.CreateBitCast(getLoadStorePointerOperand(C[0].Inst),
VecTy->getPointerTo(AS)),
getLoadStorePointerOperand(C[0].Inst),
Alignment);
}

Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2630,11 +2630,7 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
if (auto *gep = dyn_cast<GetElementPtrInst>(AddrPart->stripPointerCasts()))
InBounds = gep->isInBounds();
AddrPart = Builder.CreateGEP(ScalarTy, AddrPart, Idx, "", InBounds);

// Cast to the vector pointer type.
unsigned AddressSpace = AddrPart->getType()->getPointerAddressSpace();
Type *PtrTy = VecTy->getPointerTo(AddressSpace);
AddrParts.push_back(Builder.CreateBitCast(AddrPart, PtrTy));
AddrParts.push_back(AddrPart);
}

State.setDebugLocFromInst(Instr);
Expand Down
24 changes: 9 additions & 15 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10256,8 +10256,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
case Instruction::ExtractValue: {
auto *LI = cast<LoadInst>(E->getSingleOperand(0));
Builder.SetInsertPoint(LI);
auto *PtrTy = PointerType::get(VecTy, LI->getPointerAddressSpace());
Value *Ptr = Builder.CreateBitCast(LI->getOperand(0), PtrTy);
Value *Ptr = LI->getPointerOperand();
LoadInst *V = Builder.CreateAlignedLoad(VecTy, Ptr, LI->getAlign());
Value *NewV = propagateMetadata(V, E->Scalars);
NewV = FinalShuffle(NewV, E);
Expand Down Expand Up @@ -10599,28 +10598,23 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
}
case Instruction::Store: {
auto *SI = cast<StoreInst>(VL0);
unsigned AS = SI->getPointerAddressSpace();

setInsertPointAfterBundle(E);

Value *VecValue = vectorizeOperand(E, 0);
VecValue = FinalShuffle(VecValue, E);

Value *ScalarPtr = SI->getPointerOperand();
Value *VecPtr = Builder.CreateBitCast(
ScalarPtr, VecValue->getType()->getPointerTo(AS));
Value *Ptr = SI->getPointerOperand();
StoreInst *ST =
Builder.CreateAlignedStore(VecValue, VecPtr, SI->getAlign());
Builder.CreateAlignedStore(VecValue, Ptr, SI->getAlign());

// The pointer operand uses an in-tree scalar, so add the new BitCast or
// StoreInst to ExternalUses to make sure that an extract will be
// generated in the future.
if (TreeEntry *Entry = getTreeEntry(ScalarPtr)) {
// The pointer operand uses an in-tree scalar, so add the new StoreInst to
// ExternalUses to make sure that an extract will be generated in the
// future.
if (TreeEntry *Entry = getTreeEntry(Ptr)) {
// Find which lane we need to extract.
unsigned FoundLane = Entry->findLaneForValue(ScalarPtr);
ExternalUses.push_back(ExternalUser(
ScalarPtr, ScalarPtr != VecPtr ? cast<User>(VecPtr) : ST,
FoundLane));
unsigned FoundLane = Entry->findLaneForValue(Ptr);
ExternalUses.push_back(ExternalUser(Ptr, ST, FoundLane));
}

Value *V = propagateMetadata(ST, E->Scalars);
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-stress/llvm-stress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ Function *GenEmptyFunction(Module *M) {
// Define a few arguments
LLVMContext &Context = M->getContext();
Type* ArgsTy[] = {
Type::getInt8PtrTy(Context),
Type::getInt32PtrTy(Context),
Type::getInt64PtrTy(Context),
PointerType::get(Context, 0),
PointerType::get(Context, 0),
PointerType::get(Context, 0),
Type::getInt32Ty(Context),
Type::getInt64Ty(Context),
Type::getInt8Ty(Context)
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/AliasAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TEST_F(AliasAnalysisTest, getModRefInfo) {
auto *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
auto *BB = BasicBlock::Create(C, "entry", F);
auto IntType = Type::getInt32Ty(C);
auto PtrType = Type::getInt32PtrTy(C);
auto PtrType = PointerType::get(C, 0);
auto *Value = ConstantInt::get(IntType, 42);
auto *Addr = ConstantPointerNull::get(PtrType);
auto Alignment = Align(IntType->getBitWidth() / 8);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static void RunRandTest(uint64_t Seed, int Size, int MinCount, int MaxCount,

std::vector<Type *> TypeArgs;
for (int i = 0; i < (Size * 2); i++)
TypeArgs.push_back(Type::getInt32PtrTy(C));
TypeArgs.push_back(PointerType::getUnqual(C));
FunctionType *FuncType =
FunctionType::get(Type::getVoidTy(C), TypeArgs, false);

Expand Down
20 changes: 10 additions & 10 deletions llvm/unittests/Analysis/PhiValuesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST(PhiValuesTest, SimplePhi) {
Type *VoidTy = Type::getVoidTy(C);
Type *I1Ty = Type::getInt1Ty(C);
Type *I32Ty = Type::getInt32Ty(C);
Type *I32PtrTy = Type::getInt32PtrTy(C);
Type *PtrTy = PointerType::get(C, 0);

// Create a function with phis that do not have other phis as incoming values
Function *F = Function::Create(FunctionType::get(VoidTy, false),
Expand All @@ -38,10 +38,10 @@ TEST(PhiValuesTest, SimplePhi) {
BranchInst::Create(Then, If);
BranchInst::Create(Then, Else);

Value *Val1 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val1", Entry);
Value *Val2 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val2", Entry);
Value *Val3 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val3", Entry);
Value *Val4 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val4", Entry);
Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);

PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
Phi1->addIncoming(Val1, If);
Expand Down Expand Up @@ -91,7 +91,7 @@ TEST(PhiValuesTest, DependentPhi) {
Type *VoidTy = Type::getVoidTy(C);
Type *I1Ty = Type::getInt1Ty(C);
Type *I32Ty = Type::getInt32Ty(C);
Type *I32PtrTy = Type::getInt32PtrTy(C);
Type *PtrTy = PointerType::get(C, 0);

// Create a function with a phi that has another phi as an incoming value
Function *F = Function::Create(FunctionType::get(VoidTy, false),
Expand All @@ -111,10 +111,10 @@ TEST(PhiValuesTest, DependentPhi) {
BranchInst::Create(End, If2);
BranchInst::Create(End, Else2);

Value *Val1 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val1", Entry);
Value *Val2 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val2", Entry);
Value *Val3 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val3", Entry);
Value *Val4 = new LoadInst(I32Ty, UndefValue::get(I32PtrTy), "val4", Entry);
Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);

PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
Phi1->addIncoming(Val1, If1);
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/Analysis/SparsePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ TEST_F(SparsePropagationTest, GlobalVariableOverDefined) {
TEST_F(SparsePropagationTest, FunctionDefined) {
Function *F =
Function::Create(FunctionType::get(Builder.getInt64Ty(),
{Type::getInt1PtrTy(Context)}, false),
{PointerType::get(Context, 0)}, false),
GlobalValue::InternalLinkage, "f", &M);
BasicBlock *If = BasicBlock::Create(Context, "if", F);
BasicBlock *Then = BasicBlock::Create(Context, "then", F);
Expand Down Expand Up @@ -412,7 +412,7 @@ TEST_F(SparsePropagationTest, FunctionDefined) {
TEST_F(SparsePropagationTest, FunctionOverDefined) {
Function *F =
Function::Create(FunctionType::get(Builder.getInt64Ty(),
{Type::getInt1PtrTy(Context)}, false),
{PointerType::get(Context, 0)}, false),
GlobalValue::InternalLinkage, "f", &M);
BasicBlock *If = BasicBlock::Create(Context, "if", F);
BasicBlock *Then = BasicBlock::Create(Context, "then", F);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/TBAATest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static StoreInst *getFunctionWithSingleStore(Module *M, StringRef Name) {
auto *F = Function::Create(FTy, Function::ExternalLinkage, Name, M);
auto *BB = BasicBlock::Create(C, "entry", F);
auto *IntType = Type::getInt32Ty(C);
auto *PtrType = Type::getInt32PtrTy(C);
auto *PtrType = PointerType::get(C, 0);
auto *SI = new StoreInst(ConstantInt::get(IntType, 42),
ConstantPointerNull::get(PtrType), BB);
ReturnInst::Create(C, nullptr, BB);
Expand Down
23 changes: 11 additions & 12 deletions llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,23 +1126,22 @@ TEST_F(OpenMPIRBuilderTest, ParallelForwardAsPointers) {
using InsertPointTy = OpenMPIRBuilder::InsertPointTy;

Type *I32Ty = Type::getInt32Ty(M->getContext());
Type *I32PtrTy = Type::getInt32PtrTy(M->getContext());
Type *StructTy = StructType::get(I32Ty, I32PtrTy);
Type *StructPtrTy = StructTy->getPointerTo();
Type *PtrTy = PointerType::get(M->getContext(), 0);
Type *StructTy = StructType::get(I32Ty, PtrTy);
Type *VoidTy = Type::getVoidTy(M->getContext());
FunctionCallee RetI32Func = M->getOrInsertFunction("ret_i32", I32Ty);
FunctionCallee TakeI32Func =
M->getOrInsertFunction("take_i32", VoidTy, I32Ty);
FunctionCallee RetI32PtrFunc = M->getOrInsertFunction("ret_i32ptr", I32PtrTy);
FunctionCallee RetI32PtrFunc = M->getOrInsertFunction("ret_i32ptr", PtrTy);
FunctionCallee TakeI32PtrFunc =
M->getOrInsertFunction("take_i32ptr", VoidTy, I32PtrTy);
M->getOrInsertFunction("take_i32ptr", VoidTy, PtrTy);
FunctionCallee RetStructFunc = M->getOrInsertFunction("ret_struct", StructTy);
FunctionCallee TakeStructFunc =
M->getOrInsertFunction("take_struct", VoidTy, StructTy);
FunctionCallee RetStructPtrFunc =
M->getOrInsertFunction("ret_structptr", StructPtrTy);
M->getOrInsertFunction("ret_structptr", PtrTy);
FunctionCallee TakeStructPtrFunc =
M->getOrInsertFunction("take_structPtr", VoidTy, StructPtrTy);
M->getOrInsertFunction("take_structPtr", VoidTy, PtrTy);
Value *I32Val = Builder.CreateCall(RetI32Func);
Value *I32PtrVal = Builder.CreateCall(RetI32PtrFunc);
Value *StructVal = Builder.CreateCall(RetStructFunc);
Expand Down Expand Up @@ -5125,8 +5124,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
LoadInst *Value = nullptr;
StoreInst *TargetStore = nullptr;
llvm::SmallVector<llvm::Value *, 2> CapturedArgs = {
Constant::getNullValue(Type::getInt32PtrTy(Ctx)),
Constant::getNullValue(Type::getInt32PtrTy(Ctx))};
Constant::getNullValue(PointerType::get(Ctx, 0)),
Constant::getNullValue(PointerType::get(Ctx, 0))};

auto BodyGenCB = [&](OpenMPIRBuilder::InsertPointTy AllocaIP,
OpenMPIRBuilder::InsertPointTy CodeGenIP)
Expand Down Expand Up @@ -5756,10 +5755,10 @@ TEST_F(OpenMPIRBuilderTest, EmitOffloadingArraysArguments) {
OpenMPIRBuilder::TargetDataRTArgs RTArgs;
OpenMPIRBuilder::TargetDataInfo Info(true, false);

auto VoidPtrTy = Type::getInt8PtrTy(Builder.getContext());
auto VoidPtrPtrTy = VoidPtrTy->getPointerTo(0);
auto VoidPtrTy = PointerType::getUnqual(Builder.getContext());
auto VoidPtrPtrTy = PointerType::getUnqual(Builder.getContext());
auto Int64Ty = Type::getInt64Ty(Builder.getContext());
auto Int64PtrTy = Type::getInt64PtrTy(Builder.getContext());
auto Int64PtrTy = PointerType::getUnqual(Builder.getContext());
auto Array4VoidPtrTy = ArrayType::get(VoidPtrTy, 4);
auto Array4Int64PtrTy = ArrayType::get(Int64Ty, 4);

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/IR/BasicBlockTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TEST(BasicBlockTest, TestInstructionsWithoutDebug) {
LLVMContext Ctx;

Module *M = new Module("MyModule", Ctx);
Type *ArgTy1[] = {Type::getInt32PtrTy(Ctx)};
Type *ArgTy1[] = {PointerType::getUnqual(Ctx)};
FunctionType *FT = FunctionType::get(Type::getVoidTy(Ctx), ArgTy1, false);
Argument *V = new Argument(Type::getInt32Ty(Ctx));
Function *F = Function::Create(FT, Function::ExternalLinkage, "", M);
Expand Down
70 changes: 32 additions & 38 deletions llvm/unittests/IR/ConstantsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,66 +127,60 @@ TEST(ConstantsTest, FP128Test) {

TEST(ConstantsTest, PointerCast) {
LLVMContext C;
Type *Int8PtrTy = Type::getInt8PtrTy(C);
Type *Int32PtrTy = Type::getInt32PtrTy(C);
Type *PtrTy = PointerType::get(C, 0);
Type *Int64Ty = Type::getInt64Ty(C);
VectorType *Int8PtrVecTy = FixedVectorType::get(Int8PtrTy, 4);
VectorType *Int32PtrVecTy = FixedVectorType::get(Int32PtrTy, 4);
VectorType *PtrVecTy = FixedVectorType::get(PtrTy, 4);
VectorType *Int64VecTy = FixedVectorType::get(Int64Ty, 4);
VectorType *Int8PtrScalableVecTy = ScalableVectorType::get(Int8PtrTy, 4);
VectorType *Int32PtrScalableVecTy = ScalableVectorType::get(Int32PtrTy, 4);
VectorType *PtrScalableVecTy = ScalableVectorType::get(PtrTy, 4);
VectorType *Int64ScalableVecTy = ScalableVectorType::get(Int64Ty, 4);

// ptrtoint i8* to i64
// ptrtoint ptr to i64
EXPECT_EQ(
Constant::getNullValue(Int64Ty),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrTy), Int64Ty));
ConstantExpr::getPointerCast(Constant::getNullValue(PtrTy), Int64Ty));

// bitcast i8* to i32*
EXPECT_EQ(Constant::getNullValue(Int32PtrTy),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrTy),
Int32PtrTy));
// bitcast ptr to ptr
EXPECT_EQ(Constant::getNullValue(PtrTy),
ConstantExpr::getPointerCast(Constant::getNullValue(PtrTy), PtrTy));

// ptrtoint <4 x i8*> to <4 x i64>
// ptrtoint <4 x ptr> to <4 x i64>
EXPECT_EQ(Constant::getNullValue(Int64VecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrVecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(PtrVecTy),
Int64VecTy));

// ptrtoint <vscale x 4 x i8*> to <vscale x 4 x i64>
EXPECT_EQ(
Constant::getNullValue(Int64ScalableVecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrScalableVecTy),
Int64ScalableVecTy));

// bitcast <4 x i8*> to <4 x i32*>
EXPECT_EQ(Constant::getNullValue(Int32PtrVecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrVecTy),
Int32PtrVecTy));
// ptrtoint <vscale x 4 x ptr> to <vscale x 4 x i64>
EXPECT_EQ(Constant::getNullValue(Int64ScalableVecTy),
ConstantExpr::getPointerCast(
Constant::getNullValue(PtrScalableVecTy), Int64ScalableVecTy));

// bitcast <vscale x 4 x i8*> to <vscale x 4 x i32*>
// bitcast <4 x ptr> to <4 x ptr>
EXPECT_EQ(
Constant::getNullValue(Int32PtrScalableVecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(Int8PtrScalableVecTy),
Int32PtrScalableVecTy));
Constant::getNullValue(PtrVecTy),
ConstantExpr::getPointerCast(Constant::getNullValue(PtrVecTy), PtrVecTy));

// bitcast <vscale x 4 x ptr> to <vscale x 4 x ptr>
EXPECT_EQ(Constant::getNullValue(PtrScalableVecTy),
ConstantExpr::getPointerCast(
Constant::getNullValue(PtrScalableVecTy), PtrScalableVecTy));

Type *Int32Ptr1Ty = Type::getInt32PtrTy(C, 1);
Type *Ptr1Ty = PointerType::get(C, 1);
ConstantInt *K = ConstantInt::get(Type::getInt64Ty(C), 1234);

// Make sure that addrspacecast of inttoptr is not folded away.
EXPECT_NE(K, ConstantExpr::getAddrSpaceCast(
ConstantExpr::getIntToPtr(K, Int32PtrTy), Int32Ptr1Ty));
ConstantExpr::getIntToPtr(K, PtrTy), Ptr1Ty));
EXPECT_NE(K, ConstantExpr::getAddrSpaceCast(
ConstantExpr::getIntToPtr(K, Int32Ptr1Ty), Int32PtrTy));
ConstantExpr::getIntToPtr(K, Ptr1Ty), PtrTy));

Constant *NullInt32Ptr0 = Constant::getNullValue(Int32PtrTy);
Constant *NullInt32Ptr1 = Constant::getNullValue(Int32Ptr1Ty);
Constant *NullPtr0 = Constant::getNullValue(PtrTy);
Constant *NullPtr1 = Constant::getNullValue(Ptr1Ty);

// Make sure that addrspacecast of null is not folded away.
EXPECT_NE(Constant::getNullValue(Int32PtrTy),
ConstantExpr::getAddrSpaceCast(NullInt32Ptr0, Int32Ptr1Ty));
EXPECT_NE(Constant::getNullValue(PtrTy),
ConstantExpr::getAddrSpaceCast(NullPtr0, Ptr1Ty));

EXPECT_NE(Constant::getNullValue(Int32Ptr1Ty),
ConstantExpr::getAddrSpaceCast(NullInt32Ptr1, Int32PtrTy));
EXPECT_NE(Constant::getNullValue(Ptr1Ty),
ConstantExpr::getAddrSpaceCast(NullPtr1, PtrTy));
}

#define CHECK(x, y) \
Expand Down Expand Up @@ -668,7 +662,7 @@ TEST(ConstantsTest, isElementWiseEqual) {
EXPECT_FALSE(CF12U2->isElementWiseEqual(CF12U1));
EXPECT_FALSE(CF12U1->isElementWiseEqual(CF12U2));

PointerType *PtrTy = Type::getInt8PtrTy(Context);
PointerType *PtrTy = PointerType::get(Context, 0);
Constant *CPU = UndefValue::get(PtrTy);
Constant *CP0 = ConstantPointerNull::get(PtrTy);

Expand Down
6 changes: 3 additions & 3 deletions llvm/unittests/IR/InstructionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ TEST(InstructionsTest, isEliminableCastPair) {
Type* Int16Ty = Type::getInt16Ty(C);
Type* Int32Ty = Type::getInt32Ty(C);
Type* Int64Ty = Type::getInt64Ty(C);
Type* Int64PtrTy = Type::getInt64PtrTy(C);
Type *Int64PtrTy = PointerType::get(C, 0);

// Source and destination pointers have same size -> bitcast.
EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt,
Expand Down Expand Up @@ -680,8 +680,8 @@ TEST(InstructionsTest, isEliminableCastPair) {
"-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64"
"-v128:128:128-a:0:64-s:64:64-f80:128:128-n8:16:32:64-S128");

Type* Int64PtrTyAS1 = Type::getInt64PtrTy(C, 1);
Type* Int64PtrTyAS2 = Type::getInt64PtrTy(C, 2);
Type *Int64PtrTyAS1 = PointerType::get(C, 1);
Type *Int64PtrTyAS2 = PointerType::get(C, 2);

IntegerType *Int16SizePtr = DL.getIntPtrType(C, 1);
IntegerType *Int64SizePtr = DL.getIntPtrType(C, 2);
Expand Down
14 changes: 7 additions & 7 deletions llvm/unittests/IR/MetadataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ TEST_F(MDNodeTest, UniquedOnDeletedOperand) {

TEST_F(MDNodeTest, DistinctOnDeletedValueOperand) {
// i1* @GV
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
Expand Down Expand Up @@ -790,7 +790,7 @@ TEST_F(MDNodeTest, replaceWithUniquedResolvingOperand) {

TEST_F(MDNodeTest, replaceWithUniquedDeletedOperand) {
// i1* @GV
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
Expand All @@ -813,7 +813,7 @@ TEST_F(MDNodeTest, replaceWithUniquedDeletedOperand) {

TEST_F(MDNodeTest, replaceWithUniquedChangedOperand) {
// i1* @GV
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get());
Expand Down Expand Up @@ -3711,7 +3711,7 @@ TEST_F(MetadataAsValueTest, MDNodeConstant) {
typedef MetadataTest ValueAsMetadataTest;

TEST_F(ValueAsMetadataTest, UpdatesOnRAUW) {
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV0(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
auto *MD = ValueAsMetadata::get(GV0.get());
Expand Down Expand Up @@ -3783,7 +3783,7 @@ TEST_F(DIArgListTest, get) {
}

TEST_F(DIArgListTest, UpdatesOnRAUW) {
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
ConstantAsMetadata *CI =
ConstantAsMetadata::get(ConstantInt::get(Context, APInt(8, 0)));
std::unique_ptr<GlobalVariable> GV0(
Expand All @@ -3808,7 +3808,7 @@ TEST_F(DIArgListTest, UpdatesOnRAUW) {
typedef MetadataTest TrackingMDRefTest;

TEST_F(TrackingMDRefTest, UpdatesOnRAUW) {
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV0(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV0.get()));
Expand All @@ -3825,7 +3825,7 @@ TEST_F(TrackingMDRefTest, UpdatesOnRAUW) {
}

TEST_F(TrackingMDRefTest, UpdatesOnDeletion) {
Type *Ty = Type::getInt1PtrTy(Context);
Type *Ty = PointerType::getUnqual(Context);
std::unique_ptr<GlobalVariable> GV(
new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage));
TypedTrackingMDRef<ValueAsMetadata> MD(ValueAsMetadata::get(GV.get()));
Expand Down
18 changes: 10 additions & 8 deletions llvm/unittests/Transforms/Utils/CloningTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TEST_F(CloneInstruction, OverflowBits) {
}

TEST_F(CloneInstruction, Inbounds) {
V = new Argument(Type::getInt32PtrTy(context));
V = new Argument(PointerType::get(context, 0));

Constant *Z = Constant::getNullValue(Type::getInt32Ty(context));
std::vector<Value *> ops;
Expand All @@ -161,8 +161,9 @@ TEST_F(CloneInstruction, Exact) {
}

TEST_F(CloneInstruction, Attributes) {
Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
FunctionType *FT1 = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
Type *ArgTy1[] = {PointerType::get(context, 0)};
FunctionType *FT1 =
FunctionType::get(Type::getVoidTy(context), ArgTy1, false);

Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
BasicBlock *BB = BasicBlock::Create(context, "", F1);
Expand All @@ -187,8 +188,9 @@ TEST_F(CloneInstruction, Attributes) {
}

TEST_F(CloneInstruction, CallingConvention) {
Type *ArgTy1[] = { Type::getInt32PtrTy(context) };
FunctionType *FT1 = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
Type *ArgTy1[] = {PointerType::get(context, 0)};
FunctionType *FT1 =
FunctionType::get(Type::getVoidTy(context), ArgTy1, false);

Function *F1 = Function::Create(FT1, Function::ExternalLinkage);
F1->setCallingConv(CallingConv::Cold);
Expand All @@ -211,7 +213,7 @@ TEST_F(CloneInstruction, CallingConvention) {
}

TEST_F(CloneInstruction, DuplicateInstructionsToSplit) {
Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
Type *ArgTy1[] = {PointerType::get(context, 0)};
FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
V = new Argument(Type::getInt32Ty(context));

Expand Down Expand Up @@ -260,7 +262,7 @@ TEST_F(CloneInstruction, DuplicateInstructionsToSplit) {
}

TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq1) {
Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
Type *ArgTy1[] = {PointerType::get(context, 0)};
FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
V = new Argument(Type::getInt32Ty(context));

Expand Down Expand Up @@ -313,7 +315,7 @@ TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq1) {
}

TEST_F(CloneInstruction, DuplicateInstructionsToSplitBlocksEq2) {
Type *ArgTy1[] = {Type::getInt32PtrTy(context)};
Type *ArgTy1[] = {PointerType::get(context, 0)};
FunctionType *FT = FunctionType::get(Type::getVoidTy(context), ArgTy1, false);
V = new Argument(Type::getInt32Ty(context));

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/LocalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST(Local, ReplaceDbgDeclare) {
ASSERT_TRUE(Inst);
auto *DII = dyn_cast<DbgDeclareInst>(Inst);
ASSERT_TRUE(DII);
Value *NewBase = Constant::getNullValue(Type::getInt32PtrTy(C));
Value *NewBase = Constant::getNullValue(PointerType::getUnqual(C));
DIBuilder DIB(*M);
replaceDbgDeclare(AI, NewBase, DIB, DIExpression::ApplyOffset, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ TEST_F(ScalarEvolutionExpanderTest, ExpandPtrTypeSCEV) {
// expansion when the value in ValueOffsetPair is a ptr and the offset
// is not divisible by the elem type size of value.
auto *I8Ty = Type::getInt8Ty(Context);
auto *I8PtrTy = Type::getInt8PtrTy(Context);
auto *I8PtrTy = PointerType::get(Context, 0);
auto *I32Ty = Type::getInt32Ty(Context);
auto *I32PtrTy = Type::getInt32PtrTy(Context);
auto *I32PtrTy = PointerType::get(Context, 0);
FunctionType *FTy =
FunctionType::get(Type::getVoidTy(Context), std::vector<Type *>(), false);
Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
Expand Down