forked from OSchip/llvm-project
[OpenMP] Only strip runtime attributes if needed
Summary: Currently in OpenMPOpt we strip `noinline` attributes from runtime functions. This is here because the device bitcode library that we link has problems with needed definitions getting prematurely optimized out. This is only necessary for OpenMP offloading to GPUs so we should narrow the scope for where we spend time doing this. In the future this shouldn't be necessary as we move to using a linked library rather than pulling in a bitcode library in Clang.
This commit is contained in:
parent
5358457089
commit
c7243f21d3
|
@ -501,11 +501,14 @@ struct OMPInformationCache : public InformationCache {
|
|||
|
||||
// Remove the `noinline` attribute from `__kmpc`, `_OMP::` and `omp_`
|
||||
// functions, except if `optnone` is present.
|
||||
for (Function &F : M) {
|
||||
for (StringRef Prefix : {"__kmpc", "_ZN4_OMP", "omp_"})
|
||||
if (F.getName().startswith(Prefix) &&
|
||||
!F.hasFnAttribute(Attribute::OptimizeNone))
|
||||
F.removeFnAttr(Attribute::NoInline);
|
||||
if (isOpenMPDevice(M)) {
|
||||
for (Function &F : M) {
|
||||
for (StringRef Prefix : {"__kmpc", "_ZN4_OMP", "omp_"})
|
||||
if (F.hasFnAttribute(Attribute::NoInline) &&
|
||||
F.getName().startswith(Prefix) &&
|
||||
!F.hasFnAttribute(Attribute::OptimizeNone))
|
||||
F.removeFnAttr(Attribute::NoInline);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: We should attach the attributes defined in OMPKinds.def.
|
||||
|
|
|
@ -1208,7 +1208,7 @@ attributes #0 = { noinline cold }
|
|||
; CHECK: ; Function Attrs: nounwind
|
||||
; CHECK-NEXT: declare void @__kmpc_proxy_task_completed_ooo(i8*)
|
||||
|
||||
; CHECK: ; Function Attrs: cold convergent nounwind
|
||||
; CHECK: ; Function Attrs: cold convergent noinline nounwind
|
||||
; CHECK-NEXT: declare void @__kmpc_barrier_simple_spmd(%struct.ident_t* nocapture nofree readonly, i32)
|
||||
|
||||
; OPTIMISTIC: ; Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn writeonly
|
||||
|
@ -1736,7 +1736,7 @@ attributes #0 = { noinline cold }
|
|||
; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn
|
||||
; OPTIMISTIC-NEXT: declare void @__kmpc_proxy_task_completed_ooo(i8*)
|
||||
|
||||
; OPTIMISTIC: ; Function Attrs: cold convergent nounwind
|
||||
; OPTIMISTIC: ; Function Attrs: cold convergent noinline nounwind
|
||||
; OPTIMISTIC-NEXT: declare void @__kmpc_barrier_simple_spmd(%struct.ident_t* nocapture nofree readonly, i32)
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
|
|
|
@ -93,6 +93,7 @@ define void @a__ZN4_OMP_noinline() noinline nounwind {
|
|||
ret void
|
||||
}
|
||||
|
||||
!llvm.module.flags = !{!0}
|
||||
!llvm.module.flags = !{!0, !1}
|
||||
|
||||
!0 = !{i32 7, !"openmp", i32 50}
|
||||
!1 = !{i32 7, !"openmp-device", i32 50}
|
||||
|
|
Loading…
Reference in New Issue