[clang] [CIR][OpenMP] Enable lowering of the OpenMP dialect to LLVM IR (PR #178515)

Jan Leyonberg via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 08:53:12 PST 2026


================
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fopenmp -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck %s -check-prefix=CIR --input-file %t-cir.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp -emit-llvm %s -o %t.ll
+// RUN: FileCheck %s -check-prefix=OGCG --input-file %t.ll
+
+// CIR-LABEL: define dso_local i32 @main()
+// CIR: %[[STRUCTARG:.*]] = alloca { ptr, ptr }, align 8
+// CIR: %[[VAR1:.*]] = alloca i32, i64 1, align 4
+// CIR: %[[VAR2:.*]] = alloca i32, i64 1, align 4
+// CIR: %[[VAR3:.*]] = alloca i32, i64 1, align 4
+// CIR: br label %[[ENTRY:.*]]
+
+// CIR: [[ENTRY]]:
+// CIR: %[[THREAD_NUM:.*]] = call i32 @__kmpc_global_thread_num(ptr @1)
----------------
jsjodin wrote:

It is not needed in this case, but the createParallel function in the OpenMPIRBuilder always generates a call. This is a case where the code paths diverge between clang and flang codegen. Ideally both clang and flang should have used the same function from the OpenMPIRBuilder and generated the same code. On the target offloading side we were a bit more diligent about this regarding the code in clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp because we wanted to be sure that the code generated for flang would be on par with clang and that the OpenMPRbuilder genrated code could be fully tested through the clang test suite. This was mostly related to reductions and kernel launch.

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


More information about the cfe-commits mailing list