[clang] [llvm] [OpenMP] Ensure the actual kernel is annotated with launch bounds (PR #99927)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 22 13:02:53 PDT 2024


================
@@ -4569,7 +4569,17 @@ OpenMPIRBuilder::createTargetInit(const LocationDescription &Loc, bool IsSPMD,
   Constant *MayUseNestedParallelismVal = ConstantInt::getSigned(Int8, true);
   Constant *DebugIndentionLevelVal = ConstantInt::getSigned(Int16, 0);
 
-  Function *Kernel = Builder.GetInsertBlock()->getParent();
+  Function *DebugKernelWrapper = Builder.GetInsertBlock()->getParent();
+  Function *Kernel = DebugKernelWrapper;
+
+  // We need to strip the debug prefix to get the correct kernel name.
+  StringRef KernelName = Kernel->getName();
+  const std::string DebugPrefix = "_debug__";
+  if (KernelName.ends_with(DebugPrefix)) {
----------------
jhuber6 wrote:

I'm wondering if we should emit some module metadata instead of just comparing strings. Though I suppose OpenMP doesn't let the user name their kernels so it's not broken like it would be in CUDA or HIP.

https://github.com/llvm/llvm-project/pull/99927


More information about the cfe-commits mailing list