Author: JOE1994 Date: 2023-09-29T21:38:53-04:00 New Revision: 204883623ebd194669fc54435222e5bfb245b011
URL: https://github.com/llvm/llvm-project/commit/204883623ebd194669fc54435222e5bfb245b011 DIFF: https://github.com/llvm/llvm-project/commit/204883623ebd194669fc54435222e5bfb245b011.diff LOG: [NFC] Replace uses of Type::getPointerTo Replace some uses of `Type::getPointerTo` via 2 ways * Remove entirely if it's only used to support an unnecessary bitcast (remove the bitcast as well). * Replace with `PointerType::get`/`PointerType::getUnqual` NFC opaque pointer clean-up effort. Added: Modified: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/CodeGen/MicrosoftCXXABI.cpp llvm/lib/CodeGen/GlobalISel/CallLowering.cpp mlir/lib/ExecutionEngine/ExecutionEngine.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 270ff11559417d9..cbfa79e10bfefcc 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -658,9 +658,9 @@ void CGRecordLowering::computeVolatileBitfields() { void CGRecordLowering::accumulateVPtrs() { if (Layout.hasOwnVFPtr()) - Members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr, - llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)-> - getPointerTo()->getPointerTo())); + Members.push_back( + MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr, + llvm::PointerType::getUnqual(Types.getLLVMContext()))); if (Layout.hasOwnVBPtr()) Members.push_back( MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr, diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index b60aa0c07deb94d..adb5eb850b5546d 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1262,8 +1262,6 @@ void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers( Builder.CreateInBoundsGEP(CGF.Int8Ty, Int8This, VBaseOffset); // vtorDisp is always the 32-bits before the vbase in the class layout. VtorDispPtr = Builder.CreateConstGEP1_32(CGF.Int8Ty, VtorDispPtr, -4); - VtorDispPtr = Builder.CreateBitCast( - VtorDispPtr, CGF.Int32Ty->getPointerTo(AS), "vtordisp.ptr"); Builder.CreateAlignedStore(VtorDispValue, VtorDispPtr, CharUnits::fromQuantity(4)); @@ -1568,14 +1566,9 @@ void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) { if (!CGF.CurFuncIsThunk && MD->isVirtual()) { CharUnits Adjustment = getVirtualFunctionPrologueThisAdjustment(CGF.CurGD); if (!Adjustment.isZero()) { - unsigned AS = cast<llvm::PointerType>(This->getType())->getAddressSpace(); - llvm::Type *charPtrTy = CGF.Int8Ty->getPointerTo(AS), - *thisTy = This->getType(); - This = CGF.Builder.CreateBitCast(This, charPtrTy); assert(Adjustment.isPositive()); This = CGF.Builder.CreateConstInBoundsGEP1_32(CGF.Int8Ty, This, -Adjustment.getQuantity()); - This = CGF.Builder.CreateBitCast(This, thisTy, "this.adjusted"); } } setCXXABIThisValue(CGF, This); @@ -2511,9 +2504,6 @@ LValue MicrosoftCXXABI::EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, llvm::Value *V = CGF.CGM.GetAddrOfGlobalVar(VD); llvm::Type *RealVarTy = CGF.getTypes().ConvertTypeForMem(VD->getType()); - unsigned AS = cast<llvm::PointerType>(V->getType())->getAddressSpace(); - V = CGF.Builder.CreateBitCast(V, RealVarTy->getPointerTo(AS)); - CharUnits Alignment = CGF.getContext().getDeclAlign(VD); Address Addr(V, RealVarTy, Alignment); @@ -3226,9 +3216,6 @@ llvm::Value *MicrosoftCXXABI::EmitMemberDataPointerAddress( CodeGenFunction &CGF, const Expr *E, Address Base, llvm::Value *MemPtr, const MemberPointerType *MPT) { assert(MPT->isMemberDataPointer()); - unsigned AS = Base.getAddressSpace(); - llvm::Type *PType = - CGF.ConvertTypeForMem(MPT->getPointeeType())->getPointerTo(AS); CGBuilderTy &Builder = CGF.Builder; const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl(); MSInheritanceModel Inheritance = RD->getMSInheritanceModel(); @@ -3256,16 +3243,9 @@ llvm::Value *MicrosoftCXXABI::EmitMemberDataPointerAddress( Addr = Base.getPointer(); } - // Cast to char*. - Addr = Builder.CreateBitCast(Addr, CGF.Int8Ty->getPointerTo(AS)); - // Apply the offset, which we assume is non-null. - Addr = Builder.CreateInBoundsGEP(CGF.Int8Ty, Addr, FieldOffset, + return Builder.CreateInBoundsGEP(CGF.Int8Ty, Addr, FieldOffset, "memptr.offset"); - - // Cast the address to the appropriate pointer type, adopting the address - // space of the base pointer. - return Builder.CreateBitCast(Addr, PType); } llvm::Value * diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index 0b1f151135be9fc..f4bee2a539b246c 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -847,7 +847,8 @@ void CallLowering::insertSRetLoads(MachineIRBuilder &MIRBuilder, Type *RetTy, unsigned NumValues = SplitVTs.size(); Align BaseAlign = DL.getPrefTypeAlign(RetTy); - Type *RetPtrTy = RetTy->getPointerTo(DL.getAllocaAddrSpace()); + Type *RetPtrTy = + PointerType::get(RetTy->getContext(), DL.getAllocaAddrSpace()); LLT OffsetLLTy = getLLTForType(*DL.getIndexType(RetPtrTy), DL); MachinePointerInfo PtrInfo = MachinePointerInfo::getFixedStack(MF, FI); diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 4695924aa3cd0b2..9acbc9adf8140e0 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -155,9 +155,9 @@ static void packFunctionArguments(Module *module) { // Given a function `foo(<...>)`, define the interface function // `mlir_foo(i8**)`. - auto *newType = llvm::FunctionType::get( - builder.getVoidTy(), builder.getInt8PtrTy()->getPointerTo(), - /*isVarArg=*/false); + auto *newType = + llvm::FunctionType::get(builder.getVoidTy(), builder.getPtrTy(), + /*isVarArg=*/false); auto newName = makePackedFunctionName(func.getName()); auto funcCst = module->getOrInsertFunction(newName, newType); llvm::Function *interfaceFunc = cast<llvm::Function>(funcCst.getCallee()); @@ -179,7 +179,6 @@ static void packFunctionArguments(Module *module) { llvm::Value *argPtr = builder.CreateLoad(builder.getInt8PtrTy(), argPtrPtr); llvm::Type *argTy = arg.getType(); - argPtr = builder.CreateBitCast(argPtr, argTy->getPointerTo()); llvm::Value *load = builder.CreateLoad(argTy, argPtr); args.push_back(load); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits