-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[IR][unittests] Replace of PointerType::get(Type) with opaque version (NFC) #123621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IR][unittests] Replace of PointerType::get(Type) with opaque version (NFC) #123621
Conversation
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-llvm-ir Author: Mats Jun Larsen (junlarsen) ChangesIn accordance with #123569 Full diff: https://github.com/llvm/llvm-project/pull/123621.diff 8 Files Affected:
diff --git a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp b/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
index 43aa4009897eeb..014d527a9ef622 100644
--- a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
+++ b/llvm/unittests/CodeGen/LowLevelTypeTest.cpp
@@ -304,10 +304,10 @@ TEST(LowLevelTypeTest, Pointer) {
EXPECT_FALSE(VTy != VTy);
// Test Type->LLT conversion.
- Type *IRTy = PointerType::get(IntegerType::get(C, 8), AS);
+ Type *IRTy = PointerType::get(C, AS);
EXPECT_EQ(Ty, getLLTForType(*IRTy, DL));
Type *IRVTy =
- VectorType::get(PointerType::get(IntegerType::get(C, 8), AS), EC);
+ VectorType::get(PointerType::get(C, AS), EC);
EXPECT_EQ(VTy, getLLTForType(*IRVTy, DL));
}
}
diff --git a/llvm/unittests/FuzzMutate/OperationsTest.cpp b/llvm/unittests/FuzzMutate/OperationsTest.cpp
index b4a7bb70f328f9..b3ccfdd4fa3e5b 100644
--- a/llvm/unittests/FuzzMutate/OperationsTest.cpp
+++ b/llvm/unittests/FuzzMutate/OperationsTest.cpp
@@ -94,7 +94,7 @@ TEST(OperationsTest, SourcePreds) {
Constant *v8i8 = ConstantVector::getSplat(ElementCount::getFixed(8), i8);
Constant *v4f16 = ConstantVector::getSplat(ElementCount::getFixed(4), f16);
Constant *p0i32 =
- ConstantPointerNull::get(PointerType::get(i32->getType(), 0));
+ ConstantPointerNull::get(PointerType::get(Ctx, 0));
Constant *v8p0i32 =
ConstantVector::getSplat(ElementCount::getFixed(8), p0i32);
Constant *vni32 = ConstantVector::getSplat(ElementCount::getScalable(8), i32);
diff --git a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
index 8fe74e34fe4409..c0aa089c50b6be 100644
--- a/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
+++ b/llvm/unittests/FuzzMutate/RandomIRBuilderTest.cpp
@@ -328,7 +328,7 @@ TEST(RandomIRBuilderTest, createStackMemory) {
Int64Ty,
DoubleTy,
PointerType::get(Ctx, 0),
- PointerType::get(Int32Ty, 0),
+ PointerType::get(Ctx, 0),
VectorType::get(Int32Ty, 4, false),
StructType::create({Int32Ty, DoubleTy, Int64Ty}),
ArrayType::get(Int64Ty, 4),
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index ed608ba57d22ca..c8444ab7dfd3b9 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -315,7 +315,7 @@ TEST(ConstantsTest, GEPReplaceWithConstant) {
std::unique_ptr<Module> M(new Module("MyModule", Context));
Type *IntTy = Type::getInt32Ty(Context);
- Type *PtrTy = PointerType::get(IntTy, 0);
+ Type *PtrTy = PointerType::get(Context, 0);
auto *C1 = ConstantInt::get(IntTy, 1);
auto *Placeholder = new GlobalVariable(
*M, IntTy, false, GlobalValue::ExternalWeakLinkage, nullptr);
@@ -342,7 +342,7 @@ TEST(ConstantsTest, AliasCAPI) {
parseAssemblyString("@g = global i32 42", Error, Context);
GlobalVariable *G = M->getGlobalVariable("g");
Type *I16Ty = Type::getInt16Ty(Context);
- Type *I16PTy = PointerType::get(I16Ty, 0);
+ Type *I16PTy = PointerType::get(Context, 0);
Constant *Aliasee = ConstantExpr::getBitCast(G, I16PTy);
LLVMValueRef AliasRef =
LLVMAddAlias2(wrap(M.get()), wrap(I16Ty), 0, wrap(Aliasee), "a");
@@ -421,7 +421,7 @@ TEST(ConstantsTest, BitcastToGEP) {
auto *G =
new GlobalVariable(*M, S, false, GlobalValue::ExternalLinkage, nullptr);
- auto *PtrTy = PointerType::get(i32, 0);
+ auto *PtrTy = PointerType::get(Context, 0);
auto *C = ConstantExpr::getBitCast(G, PtrTy);
/* With opaque pointers, no cast is necessary. */
EXPECT_EQ(C, G);
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index b5c5510967b9fe..7d81d3a0d0848d 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -220,11 +220,11 @@ TEST(InstructionsTest, CastInst) {
Type *VScaleV4Int16Ty = ScalableVectorType::get(Int16Ty, 4);
Type *VScaleV1Int16Ty = ScalableVectorType::get(Int16Ty, 1);
- Type *Int32PtrTy = PointerType::get(Int32Ty, 0);
- Type *Int64PtrTy = PointerType::get(Int64Ty, 0);
+ Type *Int32PtrTy = PointerType::get(C, 0);
+ Type *Int64PtrTy = PointerType::get(C, 0);
- Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
- Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1);
+ Type *Int32PtrAS1Ty = PointerType::get(C, 1);
+ Type *Int64PtrAS1Ty = PointerType::get(C, 1);
Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
Type *V2Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 2);
@@ -406,8 +406,8 @@ TEST(InstructionsTest, CastCAPI) {
Type *FloatTy = Type::getFloatTy(C);
Type *DoubleTy = Type::getDoubleTy(C);
- Type *Int8PtrTy = PointerType::get(Int8Ty, 0);
- Type *Int32PtrTy = PointerType::get(Int32Ty, 0);
+ Type *Int8PtrTy = PointerType::get(C, 0);
+ Type *Int32PtrTy = PointerType::get(C, 0);
const Constant *C8 = Constant::getNullValue(Int8Ty);
const Constant *C64 = Constant::getNullValue(Int64Ty);
@@ -448,7 +448,7 @@ TEST(InstructionsTest, CastCAPI) {
EXPECT_EQ(LLVMTrunc, LLVMGetCastOpcode(wrap(CV64), true, wrap(V8x8Ty), true));
EXPECT_EQ(LLVMSExt, LLVMGetCastOpcode(wrap(CV8), true, wrap(V8x64Ty), true));
- Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
+ Type *Int32PtrAS1Ty = PointerType::get(C, 1);
Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
Type *V2Int32PtrTy = FixedVectorType::get(Int32PtrTy, 2);
const Constant *CV2ptr32 = Constant::getNullValue(V2Int32PtrTy);
@@ -463,8 +463,8 @@ TEST(InstructionsTest, VectorGep) {
// Type Definitions
Type *I8Ty = IntegerType::get(C, 8);
Type *I32Ty = IntegerType::get(C, 32);
- PointerType *Ptri8Ty = PointerType::get(I8Ty, 0);
- PointerType *Ptri32Ty = PointerType::get(I32Ty, 0);
+ PointerType *Ptri8Ty = PointerType::get(C, 0);
+ PointerType *Ptri32Ty = PointerType::get(C, 0);
VectorType *V2xi8PTy = FixedVectorType::get(Ptri8Ty, 2);
VectorType *V2xi32PTy = FixedVectorType::get(Ptri32Ty, 2);
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 19aae5edf4a220..1cae0194efbe38 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -76,7 +76,7 @@ TEST(VerifierTest, Freeze) {
FI_dbl->eraseFromParent();
// Valid type : freeze(i32*)
- PointerType *PT = PointerType::get(ITy, 0);
+ PointerType *PT = PointerType::get(C, 0);
ConstantPointerNull *CPN = ConstantPointerNull::get(PT);
FreezeInst *FI_ptr = new FreezeInst(CPN);
FI_ptr->insertBefore(RI);
diff --git a/llvm/unittests/Linker/LinkModulesTest.cpp b/llvm/unittests/Linker/LinkModulesTest.cpp
index 21c3f0ecf4bc15..758e859e32fbd3 100644
--- a/llvm/unittests/Linker/LinkModulesTest.cpp
+++ b/llvm/unittests/Linker/LinkModulesTest.cpp
@@ -160,7 +160,7 @@ static Module *getInternal(LLVMContext &Ctx) {
IRBuilder<> Builder(BB);
Builder.CreateRetVoid();
- StructType *STy = StructType::create(Ctx, PointerType::get(FTy, 0));
+ StructType *STy = StructType::create(Ctx, PointerType::get(Ctx, 0));
GlobalVariable *GV =
new GlobalVariable(*InternalM, STy, false /*=isConstant*/,
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 73dde0af8afdd7..e7987a95f1ca26 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -949,7 +949,7 @@ TEST_F(VPRecipeTest, CastVPWidenSelectRecipeToVPUserAndVPDef) {
TEST_F(VPRecipeTest, CastVPWidenGEPRecipeToVPUserAndVPDef) {
VPlan &Plan = getPlan();
IntegerType *Int32 = IntegerType::get(C, 32);
- PointerType *Int32Ptr = PointerType::get(Int32, 0);
+ PointerType *Int32Ptr = PointerType::get(C, 0);
auto *GEP = GetElementPtrInst::Create(Int32, PoisonValue::get(Int32Ptr),
PoisonValue::get(Int32));
VPValue *Op1 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
@@ -1034,7 +1034,7 @@ TEST_F(VPRecipeTest, CastVPBranchOnMaskRecipeToVPUser) {
TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) {
VPlan &Plan = getPlan();
IntegerType *Int32 = IntegerType::get(C, 32);
- PointerType *Int32Ptr = PointerType::get(Int32, 0);
+ PointerType *Int32Ptr = PointerType::get(C, 0);
auto *Load =
new LoadInst(Int32, PoisonValue::get(Int32Ptr), "", false, Align(1));
VPValue *Addr = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
@@ -1055,7 +1055,7 @@ TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) {
TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
IntegerType *Int1 = IntegerType::get(C, 1);
IntegerType *Int32 = IntegerType::get(C, 32);
- PointerType *Int32Ptr = PointerType::get(Int32, 0);
+ PointerType *Int32Ptr = PointerType::get(C, 0);
VPlan &Plan = getPlan();
{
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Type *Int8PtrTy = PointerType::get(Int8Ty, 0); | ||
Type *Int32PtrTy = PointerType::get(Int32Ty, 0); | ||
Type *Int8PtrTy = PointerType::get(C, 0); | ||
Type *Int32PtrTy = PointerType::get(C, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should combine these into one PtrTy and then drop any tests that became redundant as a result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also took care of some the same issue in the test above and below.
Looks like a unit test is failing. |
… (NFC) In accordance with llvm#123569
A lot of the old tests test the same thing twice because pointers are opaque. This removes the deduplication
89c3c95
to
080b0c9
Compare
I accidentally used the wrong renamed variable when I was doing this last night. It should be good to go now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In accordance with #123569