Skip to content

Commit

Permalink
[llvm] Replace calls to Type::getPointerTo (NFC)
Browse files Browse the repository at this point in the history
Clean-up towards removing method Type::getPointerTo.
  • Loading branch information
JOE1994 committed Nov 30, 2023
1 parent aea94c9 commit 5a31460
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void createInitOrFiniCalls(Function &F, bool IsCtor) {
LoopBB, ExitBB);
IRB.SetInsertPoint(LoopBB);
auto *CallBackPHI = IRB.CreatePHI(PtrTy, 2, "ptr");
auto *CallBack = IRB.CreateLoad(CallBackTy->getPointerTo(F.getAddressSpace()),
auto *CallBack = IRB.CreateLoad(IRB.getPtrTy(F.getAddressSpace()),
CallBackPHI, "callback");
IRB.CreateCall(CallBackTy, CallBack);
auto *NewCallBack =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static void createInitOrFiniCalls(Function &F, bool IsCtor) {
LoopBB, ExitBB);
IRB.SetInsertPoint(LoopBB);
auto *CallBackPHI = IRB.CreatePHI(PtrTy, 2, "ptr");
auto *CallBack = IRB.CreateLoad(CallBackTy->getPointerTo(F.getAddressSpace()),
auto *CallBack = IRB.CreateLoad(IRB.getPtrTy(F.getAddressSpace()),
CallBackPHI, "callback");
IRB.CreateCall(CallBackTy, CallBack);
auto *NewCallBack =
Expand Down
23 changes: 12 additions & 11 deletions llvm/unittests/IR/InstructionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ TEST(InstructionsTest, CloneCall) {
Type *Int32Ty = Type::getInt32Ty(C);
Type *ArgTys[] = {Int32Ty, Int32Ty, Int32Ty};
FunctionType *FnTy = FunctionType::get(Int32Ty, ArgTys, /*isVarArg=*/false);
Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
Value *Callee = Constant::getNullValue(PointerType::getUnqual(C));
Value *Args[] = {
ConstantInt::get(Int32Ty, 1),
ConstantInt::get(Int32Ty, 2),
Expand Down Expand Up @@ -748,7 +748,7 @@ TEST(InstructionsTest, AlterCallBundles) {
LLVMContext C;
Type *Int32Ty = Type::getInt32Ty(C);
FunctionType *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false);
Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
Value *Callee = Constant::getNullValue(PointerType::getUnqual(C));
Value *Args[] = {ConstantInt::get(Int32Ty, 42)};
OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty));
std::unique_ptr<CallInst> Call(
Expand All @@ -775,7 +775,7 @@ TEST(InstructionsTest, AlterInvokeBundles) {
LLVMContext C;
Type *Int32Ty = Type::getInt32Ty(C);
FunctionType *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false);
Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
Value *Callee = Constant::getNullValue(PointerType::getUnqual(C));
Value *Args[] = {ConstantInt::get(Int32Ty, 42)};
std::unique_ptr<BasicBlock> NormalDest(BasicBlock::Create(C));
std::unique_ptr<BasicBlock> UnwindDest(BasicBlock::Create(C));
Expand Down Expand Up @@ -1501,50 +1501,51 @@ TEST(InstructionsTest, FPCallIsFPMathOperator) {

Type *ITy = Type::getInt32Ty(C);
FunctionType *IFnTy = FunctionType::get(ITy, {});
Value *ICallee = Constant::getNullValue(IFnTy->getPointerTo());
PointerType *PtrTy = PointerType::getUnqual(C);
Value *ICallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> ICall(CallInst::Create(IFnTy, ICallee, {}, ""));
EXPECT_FALSE(isa<FPMathOperator>(ICall));

Type *VITy = FixedVectorType::get(ITy, 2);
FunctionType *VIFnTy = FunctionType::get(VITy, {});
Value *VICallee = Constant::getNullValue(VIFnTy->getPointerTo());
Value *VICallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> VICall(CallInst::Create(VIFnTy, VICallee, {}, ""));
EXPECT_FALSE(isa<FPMathOperator>(VICall));

Type *AITy = ArrayType::get(ITy, 2);
FunctionType *AIFnTy = FunctionType::get(AITy, {});
Value *AICallee = Constant::getNullValue(AIFnTy->getPointerTo());
Value *AICallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> AICall(CallInst::Create(AIFnTy, AICallee, {}, ""));
EXPECT_FALSE(isa<FPMathOperator>(AICall));

Type *FTy = Type::getFloatTy(C);
FunctionType *FFnTy = FunctionType::get(FTy, {});
Value *FCallee = Constant::getNullValue(FFnTy->getPointerTo());
Value *FCallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> FCall(CallInst::Create(FFnTy, FCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(FCall));

Type *VFTy = FixedVectorType::get(FTy, 2);
FunctionType *VFFnTy = FunctionType::get(VFTy, {});
Value *VFCallee = Constant::getNullValue(VFFnTy->getPointerTo());
Value *VFCallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> VFCall(CallInst::Create(VFFnTy, VFCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(VFCall));

Type *AFTy = ArrayType::get(FTy, 2);
FunctionType *AFFnTy = FunctionType::get(AFTy, {});
Value *AFCallee = Constant::getNullValue(AFFnTy->getPointerTo());
Value *AFCallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> AFCall(CallInst::Create(AFFnTy, AFCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(AFCall));

Type *AVFTy = ArrayType::get(VFTy, 2);
FunctionType *AVFFnTy = FunctionType::get(AVFTy, {});
Value *AVFCallee = Constant::getNullValue(AVFFnTy->getPointerTo());
Value *AVFCallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> AVFCall(
CallInst::Create(AVFFnTy, AVFCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(AVFCall));

Type *AAVFTy = ArrayType::get(AVFTy, 2);
FunctionType *AAVFFnTy = FunctionType::get(AAVFTy, {});
Value *AAVFCallee = Constant::getNullValue(AAVFFnTy->getPointerTo());
Value *AAVFCallee = Constant::getNullValue(PtrTy);
std::unique_ptr<CallInst> AAVFCall(
CallInst::Create(AAVFFnTy, AAVFCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(AAVFCall));
Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/IR/VectorBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ TEST_F(VectorBuilderTest, TestCreateLoadStore) {

auto *FloatVecTy =
FixedVectorType::get(Type::getFloatTy(Context), VectorNumElements);
auto *FloatVecPtrTy = FloatVecTy->getPointerTo();

Value *FloatVecPtr = UndefValue::get(FloatVecPtrTy);
Value *FloatVecPtr = UndefValue::get(Builder.getPtrTy(0));
Value *FloatVec = UndefValue::get(FloatVecTy);

// vp.load
Expand Down

0 comments on commit 5a31460

Please sign in to comment.