diff --git a/clang/test/OpenMP/barrier_codegen.cpp b/clang/test/OpenMP/barrier_codegen.cpp --- a/clang/test/OpenMP/barrier_codegen.cpp +++ b/clang/test/OpenMP/barrier_codegen.cpp @@ -46,7 +46,7 @@ // CLANGCG-NOT: # // IRBUILDER: ; Function Attrs: nounwind // IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) # -// IRBUILDER_OPT: ; Function Attrs: nofree nosync nounwind readonly +// IRBUILDER_OPT: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly // IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) # // CHECK: define {{.+}} [[TMAIN_INT]]( diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -251,17 +251,17 @@ __OMP_ATTRS_SET(GetterAttrs, OptimisticAttributes ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(ReadOnly), - EnumAttr(NoSync), EnumAttr(NoFree)) + EnumAttr(NoSync), EnumAttr(NoFree), EnumAttr(InaccessibleMemOnly)) : AttributeSet(EnumAttr(NoUnwind))) __OMP_ATTRS_SET(GetterArgWriteAttrs, OptimisticAttributes ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(NoSync), - EnumAttr(NoFree)) + EnumAttr(NoFree), EnumAttr(InaccessibleMemOrArgMemOnly)) : AttributeSet(EnumAttr(NoUnwind))) __OMP_ATTRS_SET(SetterAttrs, OptimisticAttributes ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(WriteOnly), - EnumAttr(NoSync), EnumAttr(NoFree)) + EnumAttr(NoSync), EnumAttr(NoFree), EnumAttr(InaccessibleMemOnly)) : AttributeSet(EnumAttr(NoUnwind))) #undef __OMP_ATTRS_SET @@ -274,10 +274,40 @@ #define __OMP_RTL_ATTRS(Name, FnAttrSet, RetAttrSet, ArgAttrSets) \ OMP_RTL_ATTRS(OMPRTL_##Name, FnAttrSet, RetAttrSet, ArgAttrSets) +__OMP_RTL_ATTRS(__kmpc_barrier, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_cancel, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_cancel_barrier, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_flush, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_global_thread_num, GetterAttrs, AttributeSet(), {}) __OMP_RTL_ATTRS(__kmpc_fork_call, AttributeSet(EnumAttr(NoUnwind)), AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_omp_taskwait, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_omp_taskyield, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_push_num_threads, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_push_proc_bind, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_serialized_parallel, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_end_serialized_parallel, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) -__OMP_RTL_ATTRS(__kmpc_global_thread_num, GetterAttrs, AttributeSet(), {}) __OMP_RTL_ATTRS(omp_get_thread_num, GetterAttrs, AttributeSet(), {}) __OMP_RTL_ATTRS(omp_get_num_threads, GetterAttrs, AttributeSet(), {}) __OMP_RTL_ATTRS(omp_get_max_threads, GetterAttrs, AttributeSet(), {}) @@ -315,6 +345,22 @@ __OMP_RTL_ATTRS(omp_set_schedule, SetterAttrs, AttributeSet(), {}) __OMP_RTL_ATTRS(omp_set_max_active_levels, SetterAttrs, AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_master, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_end_master, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_critical, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_critical_with_hint, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) +__OMP_RTL_ATTRS(__kmpc_end_critical, + AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)), + AttributeSet(), {}) + #undef __OMP_RTL_ATTRS #undef OMP_RTL_ATTRS #undef AttributeSet diff --git a/llvm/test/Transforms/OpenMP/add_attributes.ll b/llvm/test/Transforms/OpenMP/add_attributes.ll --- a/llvm/test/Transforms/OpenMP/add_attributes.ll +++ b/llvm/test/Transforms/OpenMP/add_attributes.ll @@ -9,6 +9,7 @@ %struct.omp_lock_t = type { i8* } %struct.omp_nest_lock_t = type { i8* } +%struct.ident_t = type { i32, i32, i32, i32, i8* } define void @call_all(i32 %schedule, %struct.omp_lock_t* %lock, i32 %lock_hint, %struct.omp_nest_lock_t* %nest_lock, i32 %i, i8* %s, i64 %st, i8* %vp, double %d, i32 %proc_bind, i64 %allocator_handle, i8* %cp, i64 %event_handle, i32 %pause_resource) { entry: @@ -460,6 +461,40 @@ declare dso_local i32 @omp_get_supported_active_levels() +declare void @__kmpc_barrier(%struct.ident_t*, i32) + +declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) + +declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) + +declare void @__kmpc_flush(%struct.ident_t*) + +declare i32 @__kmpc_global_thread_num(%struct.ident_t*) + +declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) + +declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) + +declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) + +declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) + +declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) + +declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) + +declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) + +declare i32 @__kmpc_master(%struct.ident_t*, i32) + +declare void @__kmpc_end_master(%struct.ident_t*, i32) + +declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) + +declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) + +declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) + ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare dso_local void @omp_set_num_threads(i32) @@ -685,67 +720,118 @@ ; CHECK: ; Function Attrs: nounwind ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) + +; CHECK: Function Attrs: nounwind +; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) + +; CHECK: Function Attrs: nounwind +; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) + +; CHECK: Function Attrs: inaccessiblemem_or_argmemonly +; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) + +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind writeonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_set_num_threads(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind writeonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_set_dynamic(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind writeonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_set_nested(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind writeonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_set_max_active_levels(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind writeonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_set_schedule(i32, i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_num_threads() #1 ; OPTIMISTIC-NOT: Function Attrs ; OPTIMISTIC: declare dso_local void @use_int(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_dynamic() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_nested() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_max_threads() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_thread_num() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_num_procs() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_in_parallel() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_in_final() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_active_level() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_level() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_ancestor_thread_num(i32) #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_team_size(i32) #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_thread_limit() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_max_active_levels() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind +; OPTIMISTIC: ; Function Attrs: inaccessiblemem_or_argmemonly nofree nosync nounwind ; OPTIMISTIC-NEXT: declare dso_local void @omp_get_schedule(i32* nocapture writeonly, i32* nocapture writeonly) #2 ; OPTIMISTIC-NOT: Function Attrs @@ -814,7 +900,7 @@ ; OPTIMISTIC-NOT: Function Attrs ; OPTIMISTIC: declare dso_local i32 @omp_get_team_num() -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_cancellation() #1 ; OPTIMISTIC-NOT: Function Attrs @@ -844,25 +930,25 @@ ; OPTIMISTIC-NOT: Function Attrs ; OPTIMISTIC: declare dso_local i32 @omp_get_device_num() -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_proc_bind() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_num_places() #1 ; OPTIMISTIC-NOT: Function Attrs ; OPTIMISTIC: declare dso_local i32 @omp_get_place_num_procs(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind +; OPTIMISTIC: ; Function Attrs: inaccessiblemem_or_argmemonly nofree nosync nounwind ; OPTIMISTIC-NEXT: declare dso_local void @omp_get_place_proc_ids(i32, i32* nocapture writeonly) #2 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_place_num() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_partition_num_places() #1 -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local void @omp_get_partition_place_nums(i32*) #1 ; OPTIMISTIC-NOT: Function Attrs @@ -907,5 +993,8 @@ ; OPTIMISTIC-NOT: Function Attrs ; OPTIMISTIC: declare dso_local i32 @omp_pause_resource_all(i32) -; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind readonly +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly ; OPTIMISTIC-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #1 + +; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind readonly +; OPTIMISTIC-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) diff --git a/llvm/test/Transforms/OpenMP/parallel_deletion.ll b/llvm/test/Transforms/OpenMP/parallel_deletion.ll --- a/llvm/test/Transforms/OpenMP/parallel_deletion.ll +++ b/llvm/test/Transforms/OpenMP/parallel_deletion.ll @@ -1,4 +1,4 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature ; RUN: opt -S -attributor -openmpopt -attributor-disable=false < %s | FileCheck %s ; RUN: opt -S -passes='attributor,cgscc(openmpopt)' -attributor-disable=false < %s | FileCheck %s ; @@ -142,7 +142,7 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 ; CHECK-NEXT: [[TMP:%.*]] = bitcast i32* [[A]] to i8* -; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull align 4 dereferenceable(4) [[TMP]]) +; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull align 4 dereferenceable(4) [[TMP]]) #0 ; CHECK-NEXT: store i32 0, i32* [[A]], align 4 ; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @0, i32 1, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*)* @.omp_outlined..3 to void (i32*, i32*, ...)*), i32* nocapture nofree nonnull align 4 dereferenceable(4) [[A]]) ; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @0, i32 1, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*)* @.omp_outlined..4 to void (i32*, i32*, ...)*), i32* nocapture nonnull align 4 dereferenceable(4) [[A]])