[llvm] 7e192db - [Linker] Convert test to opaque pointers (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 02:58:14 PST 2023


Author: Nikita Popov
Date: 2023-01-17T11:58:06+01:00
New Revision: 7e192db96d4c753c50e3e8d42d5e83072ddb84e1

URL: https://github.com/llvm/llvm-project/commit/7e192db96d4c753c50e3e8d42d5e83072ddb84e1
DIFF: https://github.com/llvm/llvm-project/commit/7e192db96d4c753c50e3e8d42d5e83072ddb84e1.diff

LOG: [Linker] Convert test to opaque pointers (NFC)

To at least somewhat preserve the test intent, remove some
pointer indirections and make types structurally different.

Added: 
    

Modified: 
    llvm/test/Linker/Inputs/testlink.ll
    llvm/test/Linker/testlink.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Linker/Inputs/testlink.ll b/llvm/test/Linker/Inputs/testlink.ll
index 22a66399be09e..ad72334e3fe04 100644
--- a/llvm/test/Linker/Inputs/testlink.ll
+++ b/llvm/test/Linker/Inputs/testlink.ll
@@ -1,13 +1,13 @@
-%intlist = type { %intlist*, i32 }
+%intlist = type { ptr, i32 }
 
 
-%Ty1 = type { %Ty2* }
+%Ty1 = type { ptr }
 %Ty2 = type opaque
 
 %VecSize = type { <10 x i32> }
 
- at GVTy1 = global %Ty1* null
- at GVTy2 = external global %Ty2*
+ at GVTy1 = global %Ty1 { ptr null }
+ at GVTy2 = external global %Ty2
 
 
 @MyVar = global i32 4
@@ -17,24 +17,24 @@
 ;; Intern in both testlink[12].ll
 @Intern1 = internal constant i32 52
 
- at Use2Intern1 = global i32* @Intern1
+ at Use2Intern1 = global ptr @Intern1
 
 ;; Intern in one but not in other
 @Intern2 = constant i32 12345
 
- at MyIntListPtr = constant { %intlist* } { %intlist* @MyIntList }
- at MyVarPtr = linkonce global { i32* } { i32* @MyVar }
+ at MyIntListPtr = constant { ptr } { ptr @MyIntList }
+ at MyVarPtr = linkonce global { ptr } { ptr @MyVar }
 @0 = constant i32 412
 
 ; Provides definition of Struct1 and of S1GV.
 %Struct1 = type { i32 }
- at S1GV = global %Struct1* null
+ at S1GV = global ptr null
 
 define i32 @foo(i32 %blah) {
-  store i32 %blah, i32* @MyVar
-  %idx = getelementptr %intlist, %intlist* @MyIntList, i64 0, i32 1
-  store i32 12, i32* %idx
-  %ack = load i32, i32* @0
+  store i32 %blah, ptr @MyVar
+  %idx = getelementptr %intlist, ptr @MyIntList, i64 0, i32 1
+  store i32 12, ptr %idx
+  %ack = load i32, ptr @0
   %fzo = add i32 %ack, %blah
   ret i32 %fzo
 }

diff  --git a/llvm/test/Linker/testlink.ll b/llvm/test/Linker/testlink.ll
index 69870b50413ce..d8940a4062022 100644
--- a/llvm/test/Linker/testlink.ll
+++ b/llvm/test/Linker/testlink.ll
@@ -1,12 +1,12 @@
 ; RUN: llvm-link %s %S/Inputs/testlink.ll -S | FileCheck %s
 
-; CHECK: %Ty1 = type { %Ty2* }
-; CHECK: %Ty2 = type { %Ty1* }
+; CHECK: %Ty1.1 = type { ptr }
+; CHECK: %Ty2 = type { ptr, ptr }
 %Ty1 = type opaque
-%Ty2 = type { %Ty1* }
+%Ty2 = type { ptr, ptr }
 
-; CHECK: %intlist = type { %intlist*, i32 }
-%intlist = type { %intlist*, i32 }
+; CHECK: %intlist = type { ptr, i32 }
+%intlist = type { ptr, i32 }
 
 ; The uses of intlist in the other file should be remapped.
 ; CHECK-NOT: {{%intlist.[0-9]}}
@@ -16,16 +16,16 @@
 %VecSize = type { <5 x i32> }
 
 %Struct1 = type opaque
- at S1GV = external global %Struct1*
+ at S1GV = external global %Struct1
 
 
- at GVTy1 = external global %Ty1*
- at GVTy2 = global %Ty2* null
+ at GVTy1 = external global %Ty1
+ at GVTy2 = global %Ty2 { ptr null, ptr null }
 
 
 ; This should stay the same
-; CHECK-DAG: @MyIntList = global %intlist { %intlist* null, i32 17 }
- at MyIntList = global %intlist { %intlist* null, i32 17 }
+; CHECK-DAG: @MyIntList = global %intlist { ptr null, i32 17 }
+ at MyIntList = global %intlist { ptr null, i32 17 }
 
 
 ; Nothing to link here.
@@ -33,8 +33,8 @@
 ; CHECK-DAG: @0 = external global i32
 @0 = external global i32
 
-define i32* @use0() {
-  ret i32* @0
+define ptr @use0() {
+  ret ptr @0
 }
 
 ; CHECK-DAG: @Inte = global i32 1
@@ -44,19 +44,19 @@ define i32* @use0() {
 ; CHECK-DAG: @Intern1 = internal constant i32 42
 @Intern1 = internal constant i32 42
 
- at UseIntern1 = global i32* @Intern1
+ at UseIntern1 = global ptr @Intern1
 
 ; This should get renamed since there is a definition that is non-internal in
 ; the other module.
 ; CHECK-DAG: @Intern2.{{[0-9]+}} = internal constant i32 792
 @Intern2 = internal constant i32 792
 
- at UseIntern2 = global i32* @Intern2
+ at UseIntern2 = global ptr @Intern2
 
-; CHECK-DAG: @MyVarPtr = linkonce global { i32* } { i32* @MyVar }
- at MyVarPtr = linkonce global { i32* } { i32* @MyVar }
+; CHECK-DAG: @MyVarPtr = linkonce global { ptr } { ptr @MyVar }
+ at MyVarPtr = linkonce global { ptr } { ptr @MyVar }
 
- at UseMyVarPtr = global { i32* }* @MyVarPtr
+ at UseMyVarPtr = global ptr @MyVarPtr
 
 ; CHECK-DAG: @MyVar = global i32 4
 @MyVar = external global i32
@@ -81,15 +81,15 @@ declare i32 @foo(i32)
 declare void @print(i32)
 
 define void @main() {
-  %v1 = load i32, i32* @MyVar
+  %v1 = load i32, ptr @MyVar
   call void @print(i32 %v1)
-  %idx = getelementptr %intlist, %intlist* @MyIntList, i64 0, i32 1
-  %v2 = load i32, i32* %idx
+  %idx = getelementptr %intlist, ptr @MyIntList, i64 0, i32 1
+  %v2 = load i32, ptr %idx
   call void @print(i32 %v2)
   %1 = call i32 @foo(i32 5)
-  %v3 = load i32, i32* @MyVar
+  %v3 = load i32, ptr @MyVar
   call void @print(i32 %v3)
-  %v4 = load i32, i32* %idx
+  %v4 = load i32, ptr %idx
   call void @print(i32 %v4)
   ret void
 }


        


More information about the llvm-commits mailing list