[llvm-branch-commits] [clang] [llvm] [OpenMP][clang] 6.0: num_threads strict (part 3: codegen) (PR #146405)
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 22 10:20:59 PDT 2025
================
@@ -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))
----------------
alexey-bataev wrote:
This casting should be performed in Sem, so, you should expect expression of type `const char *` here
https://github.com/llvm/llvm-project/pull/146405
More information about the llvm-branch-commits
mailing list