https://github.com/nicebert created https://github.com/llvm/llvm-project/pull/233849
Under the default off -openmp-ir-builder-optimistic-attributes flag the loop bounds get attributed as captures(none) nofree. Changing them to AttributeSet() removes those claims from the __kmpc_taskloop and __kmpc_taskloop_5 declarations. The runtime uses the bounds' addresses to locate the bounds for each task it creates. Even though the memory also reachtes the runtime through the task argument the claims in the IR about the arguments are still wrong. Depends on: llvm/llvm-project#232938 Assisted by: Claude Opus 5.5 >From 8d844d8022e0dba488efa7b42dd5d41ae406f7a4 Mon Sep 17 00:00:00 2001 From: Jonas Paulsson <[email protected]> Date: Fri, 16 Oct 2026 13:24:44 -0700 Subject: [PATCH 1/3] [OpenMP] Add arg extensions. --- .../taskloop_strictmodifier_codegen.cpp | 64 +++++++++---------- .../include/llvm/Frontend/OpenMP/OMPKinds.def | 9 ++- llvm/test/Transforms/OpenMP/add_attributes.ll | 24 ++++++- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp b/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp index 546762d540f1c..813a5c47b1def 100644 --- a/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp +++ b/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp @@ -35,7 +35,7 @@ struct S { #endif -// CHECK-LABEL: define noundef i32 @main( +// CHECK-LABEL: define noundef i32 @main(- // CHECK-SAME: i32 noundef [[ARGC:%.*]], ptr noundef [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARGC_ADDR:%.*]] = alloca i32, align 4 @@ -63,7 +63,7 @@ struct S { // CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP7]], i64 72 // CHECK-NEXT: store i64 0, ptr [[TMP11]], align 8 // CHECK-NEXT: [[TMP12:%.*]] = zext i32 [[TMP6]] to i64 -// CHECK-NEXT: tail call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr [[TMP7]], i32 1, ptr nonnull [[TMP8]], ptr nonnull [[TMP9]], i64 1, i32 1, i32 1, i64 [[TMP12]], i32 1, ptr null) #[[ATTR1:[0-9]+]] +// CHECK-NEXT: tail call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr [[TMP7]], i32 1, ptr nonnull [[TMP8]], ptr nonnull [[TMP9]], i64 1, i32 1, i32 1, i64 [[TMP12]], i32 1, ptr null) // CHECK-NEXT: tail call void @__kmpc_end_master(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: br label %[[OMP_IF_END]] // CHECK: [[OMP_IF_END]]: @@ -100,7 +100,7 @@ struct S { // CHECK-NEXT: store i64 1, ptr [[TMP24]], align 8, !tbaa [[LONG_TBAA16]] // CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP18]], i64 72 // CHECK-NEXT: store i64 0, ptr [[TMP25]], align 8 -// CHECK-NEXT: call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr nonnull [[TMP18]], i32 [[TMP21]], ptr nonnull [[TMP22]], ptr nonnull [[TMP23]], i64 1, i32 1, i32 2, i64 4, i32 1, ptr null) #[[ATTR1]] +// CHECK-NEXT: call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr nonnull [[TMP18]], i32 [[TMP21]], ptr nonnull [[TMP22]], ptr nonnull [[TMP23]], i64 1, i32 1, i32 2, i64 4, i32 1, ptr null) // CHECK-NEXT: call void @__kmpc_end_taskgroup(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: call void @__kmpc_end_master(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: br label %[[OMP_IF_END17]] @@ -134,15 +134,15 @@ struct S { // CHECK-NEXT: [[TMP3:%.*]] = load i64, ptr [[TMP2]], align 8, !tbaa [[LONG_TBAA29:![0-9]+]] // CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP1]], i64 48 // CHECK-NEXT: [[TMP5:%.*]] = load i64, ptr [[TMP4]], align 8, !tbaa [[LONG_TBAA30:![0-9]+]] -// CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[TMP3]], 32 -// CHECK-NEXT: [[TMP6:%.*]] = ashr exact i64 [[SEXT]], 32 +// CHECK-NEXT: [[TMP6:%.*]] = shl i64 [[TMP3]], 32 +// CHECK-NEXT: [[TMP7:%.*]] = ashr exact i64 [[TMP6]], 32 // CHECK-NEXT: br label %[[OMP_INNER_FOR_COND_I:.*]] // CHECK: [[OMP_INNER_FOR_COND_I]]: -// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP6]], %[[ENTRY]] ] +// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP7]], %[[ENTRY]] ] // CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP5]], [[INDVARS_IV]] // CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 -// CHECK-NEXT: br i1 [[CMP_NOT_I]], [[DOTOMP_OUTLINED__1_EXIT:label %.*]], label %[[OMP_INNER_FOR_COND_I]] -// CHECK: [[_OMP_OUTLINED__1_EXIT:.*:]] +// CHECK-NEXT: br i1 [[CMP_NOT_I]], label %[[DOTOMP_OUTLINED__1_EXIT:.*]], label %[[OMP_INNER_FOR_COND_I]] +// CHECK: [[DOTOMP_OUTLINED__1_EXIT]]: // CHECK-NEXT: ret i32 0 // // @@ -151,7 +151,7 @@ struct S { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[TMP2:%.*]] = tail call i32 @__kmpc_master(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: [[DOTNOT_I:%.*]] = icmp eq i32 [[TMP2]], 0 -// CHECK-NEXT: br i1 [[DOTNOT_I]], [[DOTOMP_OUTLINED__EXIT:label %.*]], label %[[OMP_IF_THEN_I:.*]] +// CHECK-NEXT: br i1 [[DOTNOT_I]], label %[[DOTOMP_OUTLINED__EXIT:.*]], label %[[OMP_IF_THEN_I:.*]] // CHECK: [[OMP_IF_THEN_I]]: // CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP1]], i64 40 // CHECK-NEXT: tail call void @__kmpc_taskgroup(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) @@ -170,8 +170,8 @@ struct S { // CHECK-NEXT: tail call void @__kmpc_taskloop(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr [[TMP5]], i32 1, ptr nonnull [[TMP7]], ptr nonnull [[TMP8]], i64 1, i32 1, i32 0, i64 0, ptr null) // CHECK-NEXT: tail call void @__kmpc_end_taskgroup(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: tail call void @__kmpc_end_master(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) -// CHECK-NEXT: br [[DOTOMP_OUTLINED__EXIT]] -// CHECK: [[_OMP_OUTLINED__EXIT:.*:]] +// CHECK-NEXT: br label %[[DOTOMP_OUTLINED__EXIT]] +// CHECK: [[DOTOMP_OUTLINED__EXIT]]: // CHECK-NEXT: ret i32 0 // // @@ -182,15 +182,15 @@ struct S { // CHECK-NEXT: [[TMP3:%.*]] = load i64, ptr [[TMP2]], align 8, !tbaa [[LONG_TBAA29]] // CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP1]], i64 48 // CHECK-NEXT: [[TMP5:%.*]] = load i64, ptr [[TMP4]], align 8, !tbaa [[LONG_TBAA30]] -// CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[TMP3]], 32 -// CHECK-NEXT: [[TMP6:%.*]] = ashr exact i64 [[SEXT]], 32 +// CHECK-NEXT: [[TMP6:%.*]] = shl i64 [[TMP3]], 32 +// CHECK-NEXT: [[TMP7:%.*]] = ashr exact i64 [[TMP6]], 32 // CHECK-NEXT: br label %[[OMP_INNER_FOR_COND_I:.*]] // CHECK: [[OMP_INNER_FOR_COND_I]]: -// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP6]], %[[ENTRY]] ] +// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP7]], %[[ENTRY]] ] // CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP5]], [[INDVARS_IV]] // CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 -// CHECK-NEXT: br i1 [[CMP_NOT_I]], [[DOTOMP_OUTLINED__3_EXIT:label %.*]], label %[[OMP_INNER_FOR_COND_I]] -// CHECK: [[_OMP_OUTLINED__3_EXIT:.*:]] +// CHECK-NEXT: br i1 [[CMP_NOT_I]], label %[[DOTOMP_OUTLINED__3_EXIT:.*]], label %[[OMP_INNER_FOR_COND_I]] +// CHECK: [[DOTOMP_OUTLINED__3_EXIT]]: // CHECK-NEXT: ret i32 0 // // @@ -206,7 +206,7 @@ struct S { // CHECK-NEXT: [[TMP7:%.*]] = load ptr, ptr [[TMP2]], align 8, !tbaa [[INTPTR_TBAA34:![0-9]+]], !alias.scope [[META31]], !nonnull [[META36:![0-9]+]], !align [[META37:![0-9]+]] // CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP7]], align 4, !tbaa [[INT_TBAA7]], !noalias [[META31]] // CHECK-NEXT: [[CMP_I:%.*]] = icmp sgt i32 [[TMP8]], 0 -// CHECK-NEXT: br i1 [[CMP_I]], label %[[LAND_LHS_TRUE_I:.*]], [[DOTOMP_OUTLINED__5_EXIT:label %.*]] +// CHECK-NEXT: br i1 [[CMP_I]], label %[[LAND_LHS_TRUE_I:.*]], label %[[DOTOMP_OUTLINED__5_EXIT:.*]] // CHECK: [[LAND_LHS_TRUE_I]]: // CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP2]], i64 8 // CHECK-NEXT: [[TMP10:%.*]] = load ptr, ptr [[TMP9]], align 8, !tbaa [[CHARPTR_TBAA38:![0-9]+]], !alias.scope [[META31]], !nonnull [[META36]], !align [[META39:![0-9]+]] @@ -218,13 +218,13 @@ struct S { // CHECK-NEXT: [[TMP13:%.*]] = load i8, ptr [[ARRAYIDX5_I]], align 1, !tbaa [[CHAR_TBAA20]], !noalias [[META31]] // CHECK-NEXT: [[CONV_I:%.*]] = sext i8 [[TMP13]] to i32 // CHECK-NEXT: [[CMP13_I:%.*]] = icmp slt i32 [[TMP8]], [[CONV_I]] -// CHECK-NEXT: br i1 [[CMP13_I]], label %[[OMP_INNER_FOR_COND_I:.*]], [[DOTOMP_OUTLINED__5_EXIT]] +// CHECK-NEXT: br i1 [[CMP13_I]], label %[[OMP_INNER_FOR_COND_I:.*]], label %[[DOTOMP_OUTLINED__5_EXIT]] // CHECK: [[OMP_INNER_FOR_COND_I]]: // CHECK-NEXT: [[DOTOMP_IV_0_I:%.*]] = phi i64 [ [[ADD46_I:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP4]], %[[LAND_LHS_TRUE_I]] ] // CHECK-NEXT: [[CMP16_NOT_I:%.*]] = icmp ugt i64 [[DOTOMP_IV_0_I]], [[TMP6]] // CHECK-NEXT: [[ADD46_I]] = add nsw i64 [[DOTOMP_IV_0_I]], 1 -// CHECK-NEXT: br i1 [[CMP16_NOT_I]], [[DOTOMP_OUTLINED__5_EXIT]], label %[[OMP_INNER_FOR_COND_I]] -// CHECK: [[_OMP_OUTLINED__5_EXIT:.*:]] +// CHECK-NEXT: br i1 [[CMP16_NOT_I]], label %[[DOTOMP_OUTLINED__5_EXIT]], label %[[OMP_INNER_FOR_COND_I]] +// CHECK: [[DOTOMP_OUTLINED__5_EXIT]]: // CHECK-NEXT: ret i32 0 // // @@ -238,20 +238,20 @@ struct S { // CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[TMP3]], 32 // CHECK-NEXT: [[CONV1_I2:%.*]] = ashr exact i64 [[SEXT]], 32 // CHECK-NEXT: [[CMP_NOT_I3:%.*]] = icmp ult i64 [[TMP5]], [[CONV1_I2]] -// CHECK-NEXT: br i1 [[CMP_NOT_I3]], [[DOTOMP_OUTLINED__7_EXIT:label %.*]], label %[[OMP_INNER_FOR_BODY_I:.*]] +// CHECK-NEXT: br i1 [[CMP_NOT_I3]], label %[[DOTOMP_OUTLINED__7_EXIT:.*]], label %[[OMP_INNER_FOR_BODY_I:.*]] // CHECK: [[OMP_INNER_FOR_BODY_I]]: // CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[DOTCANCEL_CONTINUE_I:.*]] ], [ [[CONV1_I2]], %[[ENTRY]] ] // CHECK-NEXT: [[TMP6:%.*]] = tail call i32 @__kmpc_cancel(ptr nonnull @[[GLOB1]], i32 [[TMP0]], i32 4) // CHECK-NEXT: [[DOTNOT_I:%.*]] = icmp eq i32 [[TMP6]], 0 -// CHECK-NEXT: br i1 [[DOTNOT_I]], label %[[DOTCANCEL_CONTINUE_I]], [[DOTOMP_OUTLINED__7_EXIT]] -// CHECK: [[_CANCEL_CONTINUE_I:.*:]] +// CHECK-NEXT: br i1 [[DOTNOT_I]], label %[[DOTCANCEL_CONTINUE_I]], label %[[DOTOMP_OUTLINED__7_EXIT]] +// CHECK: [[DOTCANCEL_CONTINUE_I]]: // CHECK-NEXT: [[TMP7:%.*]] = tail call i32 @__kmpc_cancellationpoint(ptr nonnull @[[GLOB1]], i32 [[TMP0]], i32 4) // CHECK-NEXT: [[DOTNOT12_I:%.*]] = icmp ne i32 [[TMP7]], 0 // CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 // CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP5]], [[INDVARS_IV_NEXT]] // CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[DOTNOT12_I]], i1 true, i1 [[CMP_NOT_I]] -// CHECK-NEXT: br i1 [[OR_COND]], [[DOTOMP_OUTLINED__7_EXIT]], label %[[OMP_INNER_FOR_BODY_I]] -// CHECK: [[_OMP_OUTLINED__7_EXIT:.*:]] +// CHECK-NEXT: br i1 [[OR_COND]], label %[[DOTOMP_OUTLINED__7_EXIT]], label %[[OMP_INNER_FOR_BODY_I]] +// CHECK: [[DOTOMP_OUTLINED__7_EXIT]]: // CHECK-NEXT: ret i32 0 // // @@ -284,7 +284,7 @@ struct S { // CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP4]], i64 72 // CHECK-NEXT: store i64 0, ptr [[TMP9]], align 8 // CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP2]] to i64 -// CHECK-NEXT: call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr nonnull [[TMP4]], i32 1, ptr nonnull [[TMP6]], ptr nonnull [[TMP7]], i64 1, i32 1, i32 2, i64 [[TMP10]], i32 1, ptr null) #[[ATTR1]] +// CHECK-NEXT: call void @__kmpc_taskloop_5(ptr nonnull @[[GLOB1]], i32 [[TMP0]], ptr nonnull [[TMP4]], i32 1, ptr nonnull [[TMP6]], ptr nonnull [[TMP7]], i64 1, i32 1, i32 2, i64 [[TMP10]], i32 1, ptr null) // CHECK-NEXT: call void @__kmpc_end_taskgroup(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: call void @__kmpc_end_master(ptr nonnull @[[GLOB1]], i32 [[TMP0]]) // CHECK-NEXT: br label %[[OMP_IF_END]] @@ -305,17 +305,17 @@ struct S { // CHECK-NEXT: [[TMP8:%.*]] = load ptr, ptr [[TMP7]], align 8, !tbaa [[INTPTR_TBAA47:![0-9]+]], !alias.scope [[META44]], !nonnull [[META36]], !align [[META37]] // CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[TMP8]], align 4, !tbaa [[INT_TBAA7]], !noalias [[META44]] // CHECK-NEXT: [[CMP_I:%.*]] = icmp sgt i32 [[TMP9]], 0 -// CHECK-NEXT: br i1 [[CMP_I]], label %[[TASKLOOP_IF_THEN_I:.*]], [[DOTOMP_OUTLINED__9_EXIT:label %.*]] +// CHECK-NEXT: br i1 [[CMP_I]], label %[[TASKLOOP_IF_THEN_I:.*]], label %[[DOTOMP_OUTLINED__9_EXIT:.*]] // CHECK: [[TASKLOOP_IF_THEN_I]]: -// CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[TMP4]], 32 -// CHECK-NEXT: [[TMP10:%.*]] = ashr exact i64 [[SEXT]], 32 +// CHECK-NEXT: [[TMP10:%.*]] = shl i64 [[TMP4]], 32 +// CHECK-NEXT: [[TMP11:%.*]] = ashr exact i64 [[TMP10]], 32 // CHECK-NEXT: br label %[[OMP_INNER_FOR_COND_I:.*]] // CHECK: [[OMP_INNER_FOR_COND_I]]: -// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP10]], %[[TASKLOOP_IF_THEN_I]] ] +// CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], %[[OMP_INNER_FOR_COND_I]] ], [ [[TMP11]], %[[TASKLOOP_IF_THEN_I]] ] // CHECK-NEXT: [[CMP8_NOT_I:%.*]] = icmp ult i64 [[TMP6]], [[INDVARS_IV]] // CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 -// CHECK-NEXT: br i1 [[CMP8_NOT_I]], [[DOTOMP_OUTLINED__9_EXIT]], label %[[OMP_INNER_FOR_COND_I]] -// CHECK: [[_OMP_OUTLINED__9_EXIT:.*:]] +// CHECK-NEXT: br i1 [[CMP8_NOT_I]], label %[[DOTOMP_OUTLINED__9_EXIT]], label %[[OMP_INNER_FOR_COND_I]] +// CHECK: [[DOTOMP_OUTLINED__9_EXIT]]: // CHECK-NEXT: ret i32 0 // // diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index 83ce9be8dea57..6dc100e2592cd 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -960,6 +960,10 @@ __OMP_RTL_ATTRS(__kmpc_omp_task_with_deps, DefaultAttrs, SExt, __OMP_RTL_ATTRS(__kmpc_taskloop, DefaultAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, AttributeSet(), SExt, ArgPtrAttrs, ArgPtrAttrs, AttributeSet(), SExt, SExt)) +__OMP_RTL_ATTRS(__kmpc_taskloop_5, DefaultAttrs, AttributeSet(), + ParamAttrs(ReadOnlyPtrAttrs, SExt, AttributeSet(), SExt, + ArgPtrAttrs, ArgPtrAttrs, AttributeSet(), SExt, SExt, + AttributeSet(), SExt)) __OMP_RTL_ATTRS(__kmpc_omp_target_task_alloc, DefaultAttrs, ReturnPtrAttrs, ParamAttrs(ReadOnlyPtrAttrs, SExt, SExt, SizeTyExt, SizeTyExt, ReadOnlyPtrAttrs, AttributeSet())) @@ -990,6 +994,9 @@ __OMP_RTL_ATTRS(__kmpc_fork_teams, ForkAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, ReadOnlyPtrAttrs)) __OMP_RTL_ATTRS(__kmpc_push_num_teams, InaccessibleArgOnlyAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, SExt, SExt)) +__OMP_RTL_ATTRS(__kmpc_push_num_teams_51, InaccessibleArgOnlyAttrs, + AttributeSet(), + ParamAttrs(ReadOnlyPtrAttrs, SExt, SExt, SExt, SExt)) __OMP_RTL_ATTRS(__kmpc_set_thread_limit, InaccessibleArgOnlyAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, SExt)) @@ -1038,7 +1045,7 @@ __OMP_RTL_ATTRS(__kmpc_free, AllocAttrs, AttributeSet(), __OMP_RTL_ATTRS(__tgt_interop_init, AttributeSet(), AttributeSet(), ParamAttrs(AttributeSet(), SExt, AttributeSet(), SExt, - SExt, AttributeSet(), AttributeSet(), SExt)) + SExt, SExt, AttributeSet(), SExt)) __OMP_RTL_ATTRS(__tgt_interop_destroy, AttributeSet(), AttributeSet(), ParamAttrs(AttributeSet(), SExt, AttributeSet(), SExt, SExt, AttributeSet(), SExt)) diff --git a/llvm/test/Transforms/OpenMP/add_attributes.ll b/llvm/test/Transforms/OpenMP/add_attributes.ll index f2afc67426ed5..cc6230c95a35e 100644 --- a/llvm/test/Transforms/OpenMP/add_attributes.ll +++ b/llvm/test/Transforms/OpenMP/add_attributes.ll @@ -595,10 +595,14 @@ declare i32 @__kmpc_cancellationpoint(ptr, i32, i32) declare void @__kmpc_push_num_teams(ptr, i32, i32, i32) +declare void @__kmpc_push_num_teams_51(ptr, i32, i32, i32, i32) + declare void @__kmpc_fork_teams(ptr, i32, ptr, ...) declare void @__kmpc_taskloop(ptr, i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, ptr) +declare void @__kmpc_taskloop_5(ptr, i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, i32, ptr) + declare ptr @__kmpc_omp_target_task_alloc(ptr, i32, i32, i64, i64, ptr, i64) declare ptr @__kmpc_taskred_modifier_init(ptr, i32, i32, i32, ptr) @@ -1176,12 +1180,18 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr, ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare void @__kmpc_push_num_teams(ptr, i32, i32, i32) +; CHECK: ; Function Attrs: nounwind +; CHECK-NEXT: declare void @__kmpc_push_num_teams_51(ptr, i32, i32, i32, i32) + ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare void @__kmpc_fork_teams(ptr, i32, ptr, ...) ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare void @__kmpc_taskloop(ptr, i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, ptr) +; CHECK: ; Function Attrs: nounwind +; CHECK-NEXT: declare void @__kmpc_taskloop_5(ptr, i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, i32, ptr) + ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare noalias ptr @__kmpc_omp_target_task_alloc(ptr, i32, i32, i64, i64, ptr, i64) @@ -1818,12 +1828,18 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr, ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) ; OPTIMISTIC-NEXT: declare void @__kmpc_push_num_teams(ptr nofree readonly captures(none), i32, i32, i32) +; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) +; OPTIMISTIC-NEXT: declare void @__kmpc_push_num_teams_51(ptr nofree readonly captures(none), i32, i32, i32, i32) + ; OPTIMISTIC: ; Function Attrs: nounwind ; OPTIMISTIC-NEXT: declare void @__kmpc_fork_teams(ptr nofree readonly captures(none), i32, ptr nofree readonly captures(none), ...) ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn ; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop(ptr nofree readonly captures(none), i32, ptr, i32, ptr nofree captures(none), ptr nofree captures(none), i64, i32, i32, i64, ptr) +; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn +; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop_5(ptr nofree readonly captures(none), i32, ptr, i32, ptr nofree captures(none), ptr nofree captures(none), i64, i32, i32, i64, i32, ptr) + ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn ; OPTIMISTIC-NEXT: declare noalias ptr @__kmpc_omp_target_task_alloc(ptr nofree readonly captures(none), i32, i32, i64, i64, ptr nofree readonly captures(none), i64) @@ -2476,12 +2492,18 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr, ; EXT: ; Function Attrs: nounwind ; EXT-NEXT: declare void @__kmpc_push_num_teams(ptr, i32 signext, i32 signext, i32 signext) +; EXT: ; Function Attrs: nounwind +; EXT-NEXT: declare void @__kmpc_push_num_teams_51(ptr, i32 signext, i32 signext, i32 signext, i32 signext) + ; EXT: ; Function Attrs: nounwind ; EXT-NEXT: declare void @__kmpc_fork_teams(ptr, i32 signext, ptr, ...) ; EXT: ; Function Attrs: nounwind ; EXT-NEXT: declare void @__kmpc_taskloop(ptr, i32 signext, ptr, i32 signext, ptr, ptr, i64, i32 signext, i32 signext, i64, ptr) +; EXT: ; Function Attrs: nounwind +; EXT-NEXT: declare void @__kmpc_taskloop_5(ptr, i32 signext, ptr, i32 signext, ptr, ptr, i64, i32 signext, i32 signext, i64, i32 signext, ptr) + ; EXT: ; Function Attrs: nounwind ; EXT-NEXT: declare noalias ptr @__kmpc_omp_target_task_alloc(ptr, i32 signext, i32 signext, i64, i64, ptr, i64) @@ -2690,7 +2712,7 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr, ; EXT: declare void @__tgt_interop_destroy(ptr, i32 signext, ptr, i32 signext, i32 signext, ptr, i32 signext) ; EXT-NOT: Function Attrs -; EXT: declare void @__tgt_interop_init(ptr, i32 signext, ptr, i32 signext, i32 signext, i32, ptr, i32 signext) +; EXT: declare void @__tgt_interop_init(ptr, i32 signext, ptr, i32 signext, i32 signext, i32 signext, ptr, i32 signext) ; EXT-NOT: Function Attrs ; EXT: declare void @__tgt_interop_use(ptr, i32 signext, ptr, i32 signext, i32 signext, ptr, i32 signext) >From 5e55eb9676427ac8d57429fa94f2caff0c8a12b4 Mon Sep 17 00:00:00 2001 From: Jonas Paulsson <[email protected]> Date: Mon, 19 Oct 2026 18:10:57 +0200 Subject: [PATCH 2/3] Fix test. --- clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp b/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp index 813a5c47b1def..1e1c17df4a544 100644 --- a/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp +++ b/clang/test/OpenMP/taskloop_strictmodifier_codegen.cpp @@ -35,7 +35,7 @@ struct S { #endif -// CHECK-LABEL: define noundef i32 @main(- +// CHECK-LABEL: define noundef i32 @main( // CHECK-SAME: i32 noundef [[ARGC:%.*]], ptr noundef [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARGC_ADDR:%.*]] = alloca i32, align 4 >From 68ce6f3e06de702a76951e28ae87804956de80f4 Mon Sep 17 00:00:00 2001 From: Nicole Aschenbrenner <[email protected]> Date: Tue, 20 Oct 2026 08:45:52 -0500 Subject: [PATCH 3/3] [OpenMP] Drop optimistic attributes from taskloop bound arguments Under the default off -openmp-ir-builder-optimistic-attributes flag the loop bounds get attributed as captures(none) nofree. Changing them to AttributeSet() removes those claims from the __kmpc_taskloop and __kmpc_taskloop_5 declarations. The runtime uses the bounds' addresses to locate the bounds for each task it creates. Even though the memory also reachtes the runtime through the task argument the claims in the IR about the arguments are still wrong. --- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def | 7 ++++--- llvm/test/Transforms/OpenMP/add_attributes.ll | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index 6dc100e2592cd..f85379b1e80f8 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -959,11 +959,12 @@ __OMP_RTL_ATTRS(__kmpc_omp_task_with_deps, DefaultAttrs, SExt, ReadOnlyPtrAttrs, SExt, ReadOnlyPtrAttrs)) __OMP_RTL_ATTRS(__kmpc_taskloop, DefaultAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, AttributeSet(), SExt, - ArgPtrAttrs, ArgPtrAttrs, AttributeSet(), SExt, SExt)) + AttributeSet(), AttributeSet(), AttributeSet(), SExt, + SExt)) __OMP_RTL_ATTRS(__kmpc_taskloop_5, DefaultAttrs, AttributeSet(), ParamAttrs(ReadOnlyPtrAttrs, SExt, AttributeSet(), SExt, - ArgPtrAttrs, ArgPtrAttrs, AttributeSet(), SExt, SExt, - AttributeSet(), SExt)) + AttributeSet(), AttributeSet(), AttributeSet(), SExt, + SExt, AttributeSet(), SExt)) __OMP_RTL_ATTRS(__kmpc_omp_target_task_alloc, DefaultAttrs, ReturnPtrAttrs, ParamAttrs(ReadOnlyPtrAttrs, SExt, SExt, SizeTyExt, SizeTyExt, ReadOnlyPtrAttrs, AttributeSet())) diff --git a/llvm/test/Transforms/OpenMP/add_attributes.ll b/llvm/test/Transforms/OpenMP/add_attributes.ll index cc6230c95a35e..3665da1fc1702 100644 --- a/llvm/test/Transforms/OpenMP/add_attributes.ll +++ b/llvm/test/Transforms/OpenMP/add_attributes.ll @@ -1835,10 +1835,10 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr, ; OPTIMISTIC-NEXT: declare void @__kmpc_fork_teams(ptr nofree readonly captures(none), i32, ptr nofree readonly captures(none), ...) ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn -; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop(ptr nofree readonly captures(none), i32, ptr, i32, ptr nofree captures(none), ptr nofree captures(none), i64, i32, i32, i64, ptr) +; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop(ptr nofree readonly captures(none), i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, ptr) ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn -; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop_5(ptr nofree readonly captures(none), i32, ptr, i32, ptr nofree captures(none), ptr nofree captures(none), i64, i32, i32, i64, i32, ptr) +; OPTIMISTIC-NEXT: declare void @__kmpc_taskloop_5(ptr nofree readonly captures(none), i32, ptr, i32, ptr, ptr, i64, i32, i32, i64, i32, ptr) ; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn ; OPTIMISTIC-NEXT: declare noalias ptr @__kmpc_omp_target_task_alloc(ptr nofree readonly captures(none), i32, i32, i64, i64, ptr nofree readonly captures(none), i64) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
