Generate global openmp metadata to trigger llvm openmp-opt pass

This commit is contained in:
Manuel Drehwald 2026-01-13 09:52:36 -08:00
parent 9b81629631
commit 5c85d522d0
2 changed files with 6 additions and 0 deletions

View file

@ -55,6 +55,10 @@ impl<'ll> OffloadGlobals<'ll> {
let init_ty = cx.type_func(&[], cx.type_void());
let init_rtls = declare_offload_fn(cx, "__tgt_init_all_rtls", init_ty);
// We want LLVM's openmp-opt pass to pick up and optimize this module, since it covers both
// openmp and offload optimizations.
llvm::add_module_flag_u32(cx.llmod(), llvm::ModuleFlagMergeBehavior::Max, "openmp", 51);
OffloadGlobals {
launcher_fn,
launcher_ty,

View file

@ -104,3 +104,5 @@ pub fn _kernel_1(x: &mut [f32; 256]) {
// CHECK-NEXT: call void @__tgt_unregister_lib(ptr nonnull %EmptyDesc)
// CHECK-NEXT: ret void
// CHECK-NEXT: }
// CHECK: !{i32 7, !"openmp", i32 51}