[OpenMP][FIX] Remove AssertingVHs that outlive their values
authorJohannes Doerfert <johannes@jdoerfert.de>
Thu, 8 Dec 2022 01:41:00 +0000 (17:41 -0800)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 8 Dec 2022 02:27:55 +0000 (18:27 -0800)
The map with AssertingVHs has been moved into the OpenMPIRBuilder which extended their lifetime.
On NVIDIA this will cause an assertion. This simply removes the AssertingVH wrapper.

clang/test/OpenMP/target_codegen_ref_assertion_vh.cpp [new file with mode: 0644]
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

diff --git a/clang/test/OpenMP/target_codegen_ref_assertion_vh.cpp b/clang/test/OpenMP/target_codegen_ref_assertion_vh.cpp
new file mode 100644 (file)
index 0000000..7fb2bbf
--- /dev/null
@@ -0,0 +1,11 @@
+// REQUIRES: nvptx-registered-target
+//
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.final
+// expected-no-diagnostics
+
+#pragma omp begin declare target
+constexpr int A[] = {1,2,3,4,5};
+int f(int i) { return A[i]; }
+#pragma omp end declare target
index e095147..f029e32 100644 (file)
@@ -1077,7 +1077,7 @@ public:
   /// <critical_section_name> + ".var" for "omp critical" directives; 2)
   /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
   /// variables.
-  StringMap<AssertingVH<Constant>, BumpPtrAllocator> InternalVars;
+  StringMap<Constant*, BumpPtrAllocator> InternalVars;
 
   /// Create the global variable holding the offload mappings information.
   GlobalVariable *createOffloadMaptypes(SmallVectorImpl<uint64_t> &Mappings,