llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Julian Brown (jtb20) <details> <summary>Changes</summary> The 'graph_id' clause introduced in OpenMP 6.0 lets the user attach an identifying value to a taskgraph instance, and a potentially-useful idiom is to pass a pointer expression so that each instance can uniquely depend on the pointed-to data. The corresponding runtime entry point __kmpc_taskgraph and the kmp_taskgraph_record_t::graph_id field were declared as 32-bit types, which silently truncates such pointer values on LP64 targets. Widen the field and the runtime ABI to uintptr_t, lower 'graph_id' to CGM.IntPtrTy in emitTaskgraphCall, and mark the OMPRTL descriptor as SizeTy so the call is typed consistently on 32- and 64-bit hosts. Refresh the auto-generated CHECK line in taskgraph_codegen.cpp accordingly. Assisted-By: Claude Opus 4.7 --- Full diff: https://github.com/llvm/llvm-project/pull/200403.diff 5 Files Affected: - (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+2-2) - (modified) clang/test/OpenMP/taskgraph_codegen.cpp (+1-1) - (modified) llvm/include/llvm/Frontend/OpenMP/OMPKinds.def (+1-1) - (modified) openmp/runtime/src/kmp.h (+2-2) - (modified) openmp/runtime/src/kmp_tasking.cpp (+1-1) ``````````diff diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index e770241cf4cab..9f00545cd0839 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2269,13 +2269,13 @@ void CGOpenMPRuntime::emitTaskgraphCall(CodeGenFunction &CGF, GraphReset = CGF.Builder.getInt32(0); } - llvm::Value *GraphId = CGF.Builder.getInt32(0); + llvm::Value *GraphId = llvm::ConstantInt::get(CGM.IntPtrTy, 0); const OMPGraphIdClause *GraphIdClause = D.getSingleClause<OMPGraphIdClause>(); if (GraphIdClause) { const auto *E = GraphIdClause->getId(); auto *GraphIdVal = CGF.EmitScalarExpr(E); GraphId = - CGF.Builder.CreateIntCast(GraphIdVal, CGM.Int32Ty, /*isSigned=*/false); + CGF.Builder.CreateIntCast(GraphIdVal, CGM.IntPtrTy, /*isSigned=*/false); } CodeGenFunction OutlinedCGF(CGM, /*suppressNewContext=*/true); diff --git a/clang/test/OpenMP/taskgraph_codegen.cpp b/clang/test/OpenMP/taskgraph_codegen.cpp index 3f661e6bfe3d5..e6e718c2cd6d5 100644 --- a/clang/test/OpenMP/taskgraph_codegen.cpp +++ b/clang/test/OpenMP/taskgraph_codegen.cpp @@ -22,7 +22,7 @@ // CHECK-NEXT: store ptr [[X]], ptr [[TMP1]], align 8 // CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw [[STRUCT_ANON]], ptr [[AGG_CAPTURED]], i32 0, i32 1 // CHECK-NEXT: store ptr [[Y]], ptr [[TMP2]], align 8 -// CHECK-NEXT: call void @__kmpc_taskgraph(ptr @[[GLOB1]], i32 [[TMP0]], ptr @.omp.taskgraph.handle, i32 0, i32 0, i32 0, ptr @taskgraph.omp_outlined., ptr [[AGG_CAPTURED]]) +// CHECK-NEXT: call void @__kmpc_taskgraph(ptr @[[GLOB1]], i32 [[TMP0]], ptr @.omp.taskgraph.handle, i64 0, i32 0, i32 0, ptr @taskgraph.omp_outlined., ptr [[AGG_CAPTURED]]) // CHECK-NEXT: ret i32 0 // int main() { diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index 49aeecd426a32..fc24280eaa077 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -357,7 +357,7 @@ __OMP_RTL(__kmpc_omp_task, false, Int32, IdentPtr, Int32, /* kmp_task_t */ VoidPtr) __OMP_RTL(__kmpc_end_taskgroup, false, Void, IdentPtr, Int32) __OMP_RTL(__kmpc_taskgroup, false, Void, IdentPtr, Int32) -__OMP_RTL(__kmpc_taskgraph, false, Void, IdentPtr, Int32, VoidPtrPtr, Int32, +__OMP_RTL(__kmpc_taskgraph, false, Void, IdentPtr, Int32, VoidPtrPtr, SizeTy, Int32, Int32, VoidPtr, VoidPtr) __OMP_RTL(__kmpc_taskgraph_task, false, Int32, IdentPtr, Int32, VoidPtr, Int32, SizeTy, VoidPtr, SizeTy, Int32, VoidPtr) diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index 55267161d4b8a..d660c4e191d13 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -2760,7 +2760,7 @@ typedef struct kmp_taskgraph_region { typedef struct kmp_taskgraph_record { std::atomic<kmp_taskgraph_status_t> status = KMP_TDG_NONE; kmp_int32 gtid = 0; - kmp_int32 graph_id = 0; + uintptr_t graph_id = 0; // A lock that protects the record_map and num_tasks fields from being // modified by multiple threads. // For now, we also use this whilst the taskgraph is being replayed. @@ -4502,7 +4502,7 @@ KMP_EXPORT void __kmpc_init_nest_lock_with_hint(ident_t *loc, kmp_int32 gtid, #if OMP_TASKGRAPH_EXPERIMENTAL KMP_EXPORT void __kmpc_taskgraph(ident_t *loc_ref, kmp_int32 gtid, std::atomic<void *> *tdg_handle, - kmp_uint32 graph_id, kmp_int32 graph_reset, + uintptr_t graph_id, kmp_int32 graph_reset, kmp_int32 nogroup, void (*entry)(void *), void *args); KMP_EXPORT kmp_uint32 __kmpc_taskgraph_task( diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp index a6ed83fc4748e..2f73a75f11e7c 100644 --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -5906,7 +5906,7 @@ __kmp_expire_taskgraph_records(kmp_int32 gtid, // entry: Pointer to the entry function // args: Pointer to the function arguments void __kmpc_taskgraph(ident_t *loc_ref, kmp_int32 gtid, - std::atomic<void *> *tdg_handle, kmp_uint32 graph_id, + std::atomic<void *> *tdg_handle, uintptr_t graph_id, kmp_int32 graph_reset, kmp_int32 nogroup, void (*entry)(void *), void *args) { kmp_taskgraph_header_t *header = `````````` </details> https://github.com/llvm/llvm-project/pull/200403 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
