[Openmp-commits] [llvm] [openmp] [clang] [OpenMP] Rework handling of global ctor/dtors in OpenMP (PR #71739)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Thu Nov 9 08:57:25 PST 2023

@@ -2794,6 +2794,14 @@ void ItaniumCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
   if (D.isNoDestroy(CGM.getContext()))
+  // OpenMP offloading supports C++ constructors and destructors but we do not
+  // always have 'atexit' available. Instead lower these to use the LLVM global
+  // destructors which we can handle directly in the runtime.
+  if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPIsTargetDevice &&
+      !D.isStaticLocal() &&
+      (CGM.getTriple().isAMDGPU() || CGM.getTriple().isNVPTX()))
jhuber6 wrote:

I could put something in `LangOptions` that just returns the same thing. Wasn't sure if it's worth forcing a recompile of everything though.


More information about the Openmp-commits mailing list