[clang] [clang] Recover necessary AddrSpaceCast (PR #119246)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 9 10:49:17 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Youngsuk Kim (JOE1994)
<details>
<summary>Changes</summary>
A necessary AddrSpaceCast was wrongfully deleted in 5c91b2886f6bf400b60ca7839069839ac3980f8f . Recover the AddrSpaceCast.
This fixes #<!-- -->86791 .
---
Full diff: https://github.com/llvm/llvm-project/pull/119246.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+3)
- (added) clang/test/OpenMP/amdgpu_threadprivate.cpp (+11)
``````````diff
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 8cbd09d02c7556..0abea335ad69e4 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3302,6 +3302,9 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
CharUnits Align = CGM.getContext().getDeclAlign(VD);
Val = Builder.CreateAlignedLoad(Var->getValueType(), Val, Align);
}
+ if (Val->getType() != Wrapper->getReturnType()) {
+ Val = Builder.CreateAddrSpaceCast(Val, Wrapper->getReturnType());
+ }
Builder.CreateRet(Val);
}
diff --git a/clang/test/OpenMP/amdgpu_threadprivate.cpp b/clang/test/OpenMP/amdgpu_threadprivate.cpp
new file mode 100644
index 00000000000000..5b15255ee62d4a
--- /dev/null
+++ b/clang/test/OpenMP/amdgpu_threadprivate.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: asserts
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -disable-llvm-passes -fopenmp-targets=amdgcn-amd-amdhsa -x c++ -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -target-cpu gfx906 -fopenmp -nogpulib -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -x c++ %s
+
+// Don't crash with assertions build.
+int MyGlobVar;
+#pragma omp threadprivate(MyGlobVar)
+int main() {
+ MyGlobVar = 1;
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/119246
More information about the cfe-commits
mailing list