diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 803895f64214d..94ae4cf273055 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -10759,7 +10759,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, CharUnits::fromQuantity(16)); } case NEON::BI__builtin_neon_vstrq_p128: { - llvm::Type *Int128PTy = llvm::Type::getIntNPtrTy(getLLVMContext(), 128); + llvm::Type *Int128PTy = llvm::PointerType::getUnqual(getLLVMContext()); Value *Ptr = Builder.CreateBitCast(Ops[0], Int128PTy); return Builder.CreateDefaultAlignedStore(EmitScalarExpr(E->getArg(1)), Ptr); } diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 09b6c3ac6adf4..0d2e74267e46c 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -4123,9 +4123,9 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable( // when linked against code which isn't (most of the time). llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name); if (!IvarOffsetPointer) - IvarOffsetPointer = new llvm::GlobalVariable(TheModule, - llvm::Type::getInt32PtrTy(VMContext), false, - llvm::GlobalValue::ExternalLinkage, nullptr, Name); + IvarOffsetPointer = new llvm::GlobalVariable( + TheModule, llvm::PointerType::getUnqual(VMContext), false, + llvm::GlobalValue::ExternalLinkage, nullptr, Name); return IvarOffsetPointer; } @@ -4169,10 +4169,11 @@ llvm::Value *CGObjCGNU::EmitIvarOffset(CodeGenFunction &CGF, CGF.CGM.getTarget().getTriple().isKnownWindowsMSVCEnvironment()) return CGF.Builder.CreateZExtOrBitCast( CGF.Builder.CreateAlignedLoad( - Int32Ty, CGF.Builder.CreateAlignedLoad( - llvm::Type::getInt32PtrTy(VMContext), - ObjCIvarOffsetVariable(Interface, Ivar), - CGF.getPointerAlign(), "ivar"), + Int32Ty, + CGF.Builder.CreateAlignedLoad( + llvm::PointerType::getUnqual(VMContext), + ObjCIvarOffsetVariable(Interface, Ivar), + CGF.getPointerAlign(), "ivar"), CharUnits::fromQuantity(4)), PtrDiffTy); std::string name = "__objc_ivar_offset_value_" + diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 888b7ddcccd32..270ff11559417 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -662,8 +662,9 @@ void CGRecordLowering::accumulateVPtrs() { llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)-> getPointerTo()->getPointerTo())); if (Layout.hasOwnVBPtr()) - Members.push_back(MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr, - llvm::Type::getInt32PtrTy(Types.getLLVMContext()))); + Members.push_back( + MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr, + llvm::PointerType::getUnqual(Types.getLLVMContext()))); } void CGRecordLowering::accumulateVBases() { diff --git a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp index a2a133ebc4dfc..e562c20432e37 100644 --- a/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/OffloadWrapper.cpp @@ -368,12 +368,13 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef Image, bool IsHIP) { Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { LLVMContext &C = M.getContext(); // Get the __cudaRegisterFunction function declaration. + PointerType *Int8PtrTy = PointerType::get(C, 0); + PointerType *Int8PtrPtrTy = PointerType::get(C, 0); + PointerType *Int32PtrTy = PointerType::get(C, 0); auto *RegFuncTy = FunctionType::get( Type::getInt32Ty(C), - {Type::getInt8PtrTy(C)->getPointerTo(), Type::getInt8PtrTy(C), - Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt32Ty(C), - Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), - Type::getInt8PtrTy(C), Type::getInt32PtrTy(C)}, + {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C), + Int8PtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Int32PtrTy}, /*isVarArg*/ false); FunctionCallee RegFunc = M.getOrInsertFunction( IsHIP ? "__hipRegisterFunction" : "__cudaRegisterFunction", RegFuncTy); @@ -381,8 +382,7 @@ Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { // Get the __cudaRegisterVar function declaration. auto *RegVarTy = FunctionType::get( Type::getVoidTy(C), - {Type::getInt8PtrTy(C)->getPointerTo(), Type::getInt8PtrTy(C), - Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt32Ty(C), + {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C), getSizeTTy(M), Type::getInt32Ty(C), Type::getInt32Ty(C)}, /*isVarArg*/ false); FunctionCallee RegVar = M.getOrInsertFunction( @@ -404,8 +404,7 @@ Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { : "__stop_cuda_offloading_entries"); EntriesE->setVisibility(GlobalValue::HiddenVisibility); - auto *RegGlobalsTy = FunctionType::get(Type::getVoidTy(C), - Type::getInt8PtrTy(C)->getPointerTo(), + auto *RegGlobalsTy = FunctionType::get(Type::getVoidTy(C), Int8PtrPtrTy, /*isVarArg*/ false); auto *RegGlobalsFn = Function::Create(RegGlobalsTy, GlobalValue::InternalLinkage, @@ -432,12 +431,12 @@ Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { Builder.CreateInBoundsGEP(getEntryTy(M), Entry, {ConstantInt::get(getSizeTTy(M), 0), ConstantInt::get(Type::getInt32Ty(C), 0)}); - auto *Addr = Builder.CreateLoad(Type::getInt8PtrTy(C), AddrPtr, "addr"); + auto *Addr = Builder.CreateLoad(Int8PtrTy, AddrPtr, "addr"); auto *NamePtr = Builder.CreateInBoundsGEP(getEntryTy(M), Entry, {ConstantInt::get(getSizeTTy(M), 0), ConstantInt::get(Type::getInt32Ty(C), 1)}); - auto *Name = Builder.CreateLoad(Type::getInt8PtrTy(C), NamePtr, "name"); + auto *Name = Builder.CreateLoad(Int8PtrTy, NamePtr, "name"); auto *SizePtr = Builder.CreateInBoundsGEP(getEntryTy(M), Entry, {ConstantInt::get(getSizeTTy(M), 0), @@ -454,14 +453,13 @@ Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) { // Create kernel registration code. Builder.SetInsertPoint(IfThenBB); - Builder.CreateCall(RegFunc, - {RegGlobalsFn->arg_begin(), Addr, Name, Name, - ConstantInt::get(Type::getInt32Ty(C), -1), - ConstantPointerNull::get(Type::getInt8PtrTy(C)), - ConstantPointerNull::get(Type::getInt8PtrTy(C)), - ConstantPointerNull::get(Type::getInt8PtrTy(C)), - ConstantPointerNull::get(Type::getInt8PtrTy(C)), - ConstantPointerNull::get(Type::getInt32PtrTy(C))}); + Builder.CreateCall(RegFunc, {RegGlobalsFn->arg_begin(), Addr, Name, Name, + ConstantInt::get(Type::getInt32Ty(C), -1), + ConstantPointerNull::get(Int8PtrTy), + ConstantPointerNull::get(Int8PtrTy), + ConstantPointerNull::get(Int8PtrTy), + ConstantPointerNull::get(Int8PtrTy), + ConstantPointerNull::get(Int32PtrTy)}); Builder.CreateBr(IfEndBB); Builder.SetInsertPoint(IfElseBB); diff --git a/clang/unittests/CodeGen/TBAAMetadataTest.cpp b/clang/unittests/CodeGen/TBAAMetadataTest.cpp index 2919a35c8cedf..9f64008358e4f 100644 --- a/clang/unittests/CodeGen/TBAAMetadataTest.cpp +++ b/clang/unittests/CodeGen/TBAAMetadataTest.cpp @@ -113,7 +113,7 @@ TEST(TBAAMetadataTest, BasicTypes) { I = matchNext(I, MInstruction(Instruction::Store, - MValType(Type::getInt8PtrTy(Compiler.Context)), + MValType(PointerType::getUnqual(Compiler.Context)), MMTuple( MMTuple( MMString("any pointer"), @@ -125,7 +125,7 @@ TEST(TBAAMetadataTest, BasicTypes) { I = matchNext(I, MInstruction(Instruction::Store, - MValType(Type::getInt32PtrTy(Compiler.Context)), + MValType(PointerType::getUnqual(Compiler.Context)), MMTuple( MMTuple( MMString("any pointer"), diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index 816c9a3f054e2..006708dfd7096 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -26,6 +26,7 @@ #endif #define __OMP_TYPE(VarName) OMP_TYPE(VarName, Type::get##VarName##Ty(Ctx)) +#define __OMP_PTR_TYPE(VarName) OMP_TYPE(VarName, PointerType::get(Ctx, 0)) __OMP_TYPE(Void) __OMP_TYPE(Int1) @@ -33,23 +34,21 @@ __OMP_TYPE(Int8) __OMP_TYPE(Int16) __OMP_TYPE(Int32) __OMP_TYPE(Int64) -__OMP_TYPE(Int8Ptr) -__OMP_TYPE(Int16Ptr) -__OMP_TYPE(Int32Ptr) -__OMP_TYPE(Int64Ptr) +__OMP_PTR_TYPE(Int8Ptr) +__OMP_PTR_TYPE(Int16Ptr) +__OMP_PTR_TYPE(Int32Ptr) +__OMP_PTR_TYPE(Int64Ptr) __OMP_TYPE(Double) OMP_TYPE(SizeTy, M.getDataLayout().getIntPtrType(Ctx)) OMP_TYPE(Int63, Type::getIntNTy(Ctx, 63)) -#define __OMP_PTR_TYPE(NAME, BASE) OMP_TYPE(NAME, BASE->getPointerTo()) +__OMP_PTR_TYPE(VoidPtr) +__OMP_PTR_TYPE(VoidPtrPtr) +__OMP_PTR_TYPE(VoidPtrPtrPtr) -__OMP_PTR_TYPE(VoidPtr, Int8) -__OMP_PTR_TYPE(VoidPtrPtr, VoidPtr) -__OMP_PTR_TYPE(VoidPtrPtrPtr, VoidPtrPtr) - -__OMP_PTR_TYPE(Int8PtrPtr, Int8Ptr) -__OMP_PTR_TYPE(Int8PtrPtrPtr, Int8PtrPtr) +__OMP_PTR_TYPE(Int8PtrPtr) +__OMP_PTR_TYPE(Int8PtrPtrPtr) #undef __OMP_PTR_TYPE diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index f86ce845d1915..3592de2b38572 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -558,7 +558,7 @@ class IRBuilderBase { /// Fetch the type representing a pointer to an 8-bit integer value. PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { - return Type::getInt8PtrTy(Context, AddrSpace); + return getPtrTy(AddrSpace); } /// Fetch the type of an integer with size at least as big as that of a diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 27219e89dc5f7..c01a27bd76a53 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1878,7 +1878,7 @@ void Function::allocHungoffUselist() { setNumHungOffUseOperands(3); // Initialize the uselist with placeholder operands to allow traversal. - auto *CPN = ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0)); + auto *CPN = ConstantPointerNull::get(PointerType::get(getContext(), 0)); Op<0>().set(CPN); Op<1>().set(CPN); Op<2>().set(CPN); @@ -1890,8 +1890,7 @@ void Function::setHungoffOperand(Constant *C) { allocHungoffUselist(); Op().set(C); } else if (getNumOperands()) { - Op().set( - ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0))); + Op().set(ConstantPointerNull::get(PointerType::get(getContext(), 0))); } } diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index df090c5990e6f..2d45d8557f2ef 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -937,7 +937,7 @@ IRLinker::linkAppendingVarProto(GlobalVariable *DstGV, IsOldStructor = true; } - PointerType *VoidPtrTy = Type::getInt8Ty(SrcGV->getContext())->getPointerTo(); + PointerType *VoidPtrTy = PointerType::get(SrcGV->getContext(), 0); if (IsOldStructor) { auto &ST = *cast(EltTy); Type *Tys[3] = {ST.getElementType(0), ST.getElementType(1), VoidPtrTy}; diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index 0b35f134ec7b6..1d6aaeb7433b0 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -2180,7 +2180,7 @@ unsigned ARMFastISel::ARMSelectCallOp(bool UseReg) { unsigned ARMFastISel::getLibcallReg(const Twine &Name) { // Manually compute the global's type to avoid building it when unnecessary. - Type *GVTy = Type::getInt32PtrTy(*Context, /*AS=*/0); + Type *GVTy = PointerType::get(*Context, /*AS=*/0); EVT LCREVT = TLI.getValueType(DL, GVTy); if (!LCREVT.isSimple()) return 0; @@ -2964,7 +2964,7 @@ unsigned ARMFastISel::ARMLowerPICELF(const GlobalValue *GV, MVT VT) { /*AddCurrentAddress=*/UseGOT_PREL); Align ConstAlign = - MF->getDataLayout().getPrefTypeAlign(Type::getInt32PtrTy(*Context)); + MF->getDataLayout().getPrefTypeAlign(PointerType::get(*Context, 0)); unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign); MachineMemOperand *CPMMO = MF->getMachineMemOperand(MachinePointerInfo::getConstantPool(*MF), diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index 4b8fdcf3a5b3e..37c6351bfdaa1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -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 @@ -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 Args(NumClauses, Int8PtrTy); FunctionType *FTy = FunctionType::get(Int8PtrTy, Args, false); Function *F = getEmscriptenFunction( @@ -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); } @@ -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); } @@ -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 ); } } @@ -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); @@ -1680,7 +1679,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj( FunctionType::get(IRB.getInt32Ty(), /* isVarArg */ true); Value *PersF = M.getOrInsertFunction(PersName, PersType).getCallee(); F.setPersonalityFn( - cast(IRB.CreateBitCast(PersF, IRB.getInt8PtrTy()))); + cast(IRB.CreateBitCast(PersF, IRB.getPtrTy()))); } // Use the entry BB's debugloc as a fallback @@ -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"); diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 1ca182f073c30..4879a8d776c3a 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -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) diff --git a/llvm/lib/Transforms/IPO/CrossDSOCFI.cpp b/llvm/lib/Transforms/IPO/CrossDSOCFI.cpp index 93d15f59a0363..5cc8258a495a6 100644 --- a/llvm/lib/Transforms/IPO/CrossDSOCFI.cpp +++ b/llvm/lib/Transforms/IPO/CrossDSOCFI.cpp @@ -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(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. @@ -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); diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 9b4b3efd7283e..9bb58a5d1c248 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -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); diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index a92e7d2adf4af..39b79b9134f8a 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -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()); diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index d332586423651..425d2b3611159 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -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)), diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 06a999da0671f..390b5a61450d1 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -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; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 1fa33109b4f6a..e2fecce2aeb1b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -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); } diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 83d90049abc39..75859a87fb05e 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -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); } @@ -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); } diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index adf86526ebf14..b51e4d46bffeb 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -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." @@ -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( diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 03e8a2507b45c..09438433077dd 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1998,12 +1998,12 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) { if (ConstantInt *Cond = dyn_cast(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 = diff --git a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp index d424ebbef99d1..d2dbfcfd89d16 100644 --- a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp +++ b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp @@ -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)); diff --git a/llvm/tools/llvm-stress/llvm-stress.cpp b/llvm/tools/llvm-stress/llvm-stress.cpp index d1cf1607b94be..783316d676550 100644 --- a/llvm/tools/llvm-stress/llvm-stress.cpp +++ b/llvm/tools/llvm-stress/llvm-stress.cpp @@ -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) diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp index 7ad2cf67f1310..cb8a412f329a6 100644 --- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp +++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp @@ -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); diff --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp index ef84ed5d99d68..a8a05e0caeee5 100644 --- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp +++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp @@ -421,7 +421,7 @@ static void RunRandTest(uint64_t Seed, int Size, int MinCount, int MaxCount, std::vector 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); diff --git a/llvm/unittests/Analysis/PhiValuesTest.cpp b/llvm/unittests/Analysis/PhiValuesTest.cpp index a1506515f5430..149feb15d999f 100644 --- a/llvm/unittests/Analysis/PhiValuesTest.cpp +++ b/llvm/unittests/Analysis/PhiValuesTest.cpp @@ -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), @@ -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); @@ -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), @@ -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); diff --git a/llvm/unittests/Analysis/SparsePropagation.cpp b/llvm/unittests/Analysis/SparsePropagation.cpp index f4a7a116d8904..e77eadf067170 100644 --- a/llvm/unittests/Analysis/SparsePropagation.cpp +++ b/llvm/unittests/Analysis/SparsePropagation.cpp @@ -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); @@ -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); diff --git a/llvm/unittests/Analysis/TBAATest.cpp b/llvm/unittests/Analysis/TBAATest.cpp index 5a71c74a80b59..b42542e5064e9 100644 --- a/llvm/unittests/Analysis/TBAATest.cpp +++ b/llvm/unittests/Analysis/TBAATest.cpp @@ -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); diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp index e73573c8cd7d9..4f795ba9cf7a2 100644 --- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp +++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp @@ -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); @@ -5125,8 +5124,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) { LoadInst *Value = nullptr; StoreInst *TargetStore = nullptr; llvm::SmallVector 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) @@ -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); diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp index 454cafe3fe721..3756f227143a5 100644 --- a/llvm/unittests/IR/BasicBlockTest.cpp +++ b/llvm/unittests/IR/BasicBlockTest.cpp @@ -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); diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index 265a702069898..57a0a91086a19 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -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 to - 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 to + EXPECT_EQ(Constant::getNullValue(Int64ScalableVecTy), + ConstantExpr::getPointerCast( + Constant::getNullValue(PtrScalableVecTy), Int64ScalableVecTy)); - // bitcast to + // 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 to + 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) \ @@ -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); diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index b43a8c0bc5e60..637c69204addf 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -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, @@ -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); diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 5342360109d0d..1570631287b2a 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -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 GV( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get()); @@ -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 GV( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get()); @@ -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 GV( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); ConstantAsMetadata *Op = ConstantAsMetadata::get(GV.get()); @@ -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 GV0( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); auto *MD = ValueAsMetadata::get(GV0.get()); @@ -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 GV0( @@ -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 GV0( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); TypedTrackingMDRef MD(ValueAsMetadata::get(GV0.get())); @@ -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 GV( new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage)); TypedTrackingMDRef MD(ValueAsMetadata::get(GV.get())); diff --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp index d5cd285f5bee9..01ad41f8f75aa 100644 --- a/llvm/unittests/Transforms/Utils/CloningTest.cpp +++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp @@ -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 ops; @@ -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); @@ -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); @@ -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)); @@ -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)); @@ -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)); diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp index 2c59322aca121..c888668f7aec3 100644 --- a/llvm/unittests/Transforms/Utils/LocalTest.cpp +++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -154,7 +154,7 @@ TEST(Local, ReplaceDbgDeclare) { ASSERT_TRUE(Inst); auto *DII = dyn_cast(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); diff --git a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp index eb1d487ed11de..5fb7db9eccb1f 100644 --- a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp +++ b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp @@ -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(), false); Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);