[clang] [clang] Recover necessary AddrSpaceCast (PR #119246)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 9 10:48:42 PST 2024
https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/119246
A necessary AddrSpaceCast was wrongfully deleted in 5c91b2886f6bf400b60ca7839069839ac3980f8f . Recover the AddrSpaceCast.
This fixes #86791 .
>From 9dbcf65775a979553bee2c95b16e3e2328e957a1 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Mon, 9 Dec 2024 10:33:18 -0600
Subject: [PATCH] [clang] Recover necessary AddrSpaceCast
A necessary AddrSpaceCast was wrongfully deleted in 5c91b2886f6bf400b60ca7839069839ac3980f8f .
Recover the AddrSpaceCast.
This fixes #86791 .
---
clang/lib/CodeGen/ItaniumCXXABI.cpp | 3 +++
clang/test/OpenMP/amdgpu_threadprivate.cpp | 11 +++++++++++
2 files changed, 14 insertions(+)
create mode 100644 clang/test/OpenMP/amdgpu_threadprivate.cpp
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;
+}
More information about the cfe-commits
mailing list