[llvm] [clang] [AIX][TOC] Add -mtocdata/-mno-tocdata options on AIX (PR #67999)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 13:49:29 PDT 2023


================
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata=n,_ZN11MyNamespace10myVariableE,_ZL1s,_ZZ4testvE7counter -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=CHECKIGNORE
+// RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata=n,_ZN11MyNamespace10myVariableE,_ZL1s,_ZZ4testvE7counter -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=CHECKIGNORE
+
+extern int n;
+static int s = 100;
+
+inline int test() {
+    static int counter = 0;
+    counter++;
+    return counter;
+}
+
+int a () {
+    n = test();
+    return 0;
+}
+
+namespace MyNamespace {
+    int myVariable = 10;
+}
+
+int b(int x) {
+    using namespace MyNamespace;
+    return x + myVariable;
+}
+
+int c(int x) {
+  s += x;
+  return s;
+}
+
+// CHECK: @n = external global i32, align 4 #0
+// CHECK: @_ZN11MyNamespace10myVariableE = global i32 10, align 4 #0
+// CHECK-NOT: @_ZL1s = internal global i32 100, align 4 #0
+// CHECK: @_ZZ4testvE7counter = linkonce_odr global i32 0, align 4 #0
+// CHECK: attributes #0 = { "toc-data" }
+// CHECKIGNORE: @n = external global i32, align 4 #0
+// CHECKIGNORE: @_ZN11MyNamespace10myVariableE = global i32 10, align 4 #0
+// CHECKIGNORE-NOT: @_ZL1s = internal global i32 100, align 4 #0
+// CHECKIGNORE-NOT: @_ZZ4testvE7counter = linkonce_odr global i32 0, align 4 #0
----------------
diggerlin wrote:

since the only different is 
`@_ZZ4testvE7counter = linkonce_odr global i32 0, align 4 #0`
and 
`@_ZZ4testvE7counter = linkonce_odr global i32 0, align 4`

same comment as previous test case.



https://github.com/llvm/llvm-project/pull/67999


More information about the cfe-commits mailing list