================
@@ -2699,18 +2699,33 @@ llvm::Value 
*CGOpenMPRuntime::emitForNext(CodeGenFunction &CGF,
       CGF.getContext().BoolTy, Loc);
 }
 
-void CGOpenMPRuntime::emitNumThreadsClause(CodeGenFunction &CGF,
-                                           llvm::Value *NumThreads,
-                                           SourceLocation Loc) {
+void CGOpenMPRuntime::emitNumThreadsClause(
+    CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc,
+    OpenMPNumThreadsClauseModifier Modifier, OpenMPSeverityClauseKind Severity,
+    const Expr *Message) {
   if (!CGF.HaveInsertPoint())
     return;
+  llvm::SmallVector<llvm::Value *, 4> Args(
+      {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+       CGF.Builder.CreateIntCast(NumThreads, CGF.Int32Ty, /*isSigned*/ true)});
   // Build call __kmpc_push_num_threads(&loc, global_tid, num_threads)
-  llvm::Value *Args[] = {
-      emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-      CGF.Builder.CreateIntCast(NumThreads, CGF.Int32Ty, /*isSigned*/ true)};
-  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
-                          CGM.getModule(), OMPRTL___kmpc_push_num_threads),
-                      Args);
+  // or __kmpc_push_num_threads_strict(&loc, global_tid, num_threads, severity,
+  // messsage) if strict modifier is used.
+  RuntimeFunction FnID = OMPRTL___kmpc_push_num_threads;
+  if (Modifier == OMPC_NUMTHREADS_strict) {
+    FnID = OMPRTL___kmpc_push_num_threads_strict;
+    // OpenMP 6.0, 10.4: "If no severity clause is specified then the effect is
+    // as if sev-level is fatal."
+    Args.push_back(llvm::ConstantInt::get(
+        CGM.Int32Ty, Severity == OMPC_SEVERITY_warning ? 1 : 2));
+    if (Message)
+      Args.push_back(CGF.EmitStringLiteralLValue(cast<StringLiteral>(Message))
----------------
ro-i wrote:

Currently, the message clause (which is also used for the error directive) only 
supports string literals:
https://github.com/llvm/llvm-project/blob/e94bc16b8e12a64ff28aedc58ee6e95e1f9d6f4b/clang/lib/Sema/SemaOpenMP.cpp#L16447-L16452

String literal is also assumed for the error directive's codegen:
https://github.com/llvm/llvm-project/blob/5c7c8558c856712a5ef11ff5f4e7ea7d3567f625/clang/lib/CodeGen/CGOpenMPRuntime.cpp#L2375-L2378

I can make a follow-up PR for that after we're done with this one. (Afaiu, the 
spec does not restrict the argument of the message clause to a string literal.)

https://github.com/llvm/llvm-project/pull/146405
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to