[clang] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars. (PR #75564)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 14 22:36:12 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (UmeshKalappa0)
<details>
<summary>Changes</summary>
For kernel modules (where -fno-pic and no-pie is implicit ) having "R_X86_64_REX_GOTPCRELX " relocs burden the kernel loader to handle the same like https://godbolt.org/z/hhh7ozojz.
Solution : Mark the OpenMP internal variables with dso_local conditionally for no-pic and no-pie ,then
1. reset the dso_local for thread_local and weak linkage internal vars.
---
Full diff: https://github.com/llvm/llvm-project/pull/75564.diff
1 Files Affected:
- (added) clang/test/OpenMP/gomp_critical_dso_local_var.c (+23)
``````````diff
diff --git a/clang/test/OpenMP/gomp_critical_dso_local_var.c b/clang/test/OpenMP/gomp_critical_dso_local_var.c
new file mode 100644
index 00000000000000..915f6773bf67bf
--- /dev/null
+++ b/clang/test/OpenMP/gomp_critical_dso_local_var.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s --check-prefix=DSO_LOCAL
+
+// DSO_LOCAL-DAG: @.gomp_critical_user_.var = common dso_local global [8 x i32] zeroinitializer, align 8
+int omp_critical_test()
+{
+ int sum;
+ int known_sum;
+
+ sum=0;
+#pragma omp parallel
+ {
+ int mysum=0;
+ int i;
+#pragma omp for
+ for (i = 0; i < 1000; i++)
+ mysum = mysum + i;
+#pragma omp critical
+ sum = mysum +sum;
+ }
+ known_sum = 999 * 1000 / 2;
+ return (known_sum == sum);
+}
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/75564
More information about the cfe-commits
mailing list