[PATCH] D105196: [OpenMP] Change analysis remarks to not emit on cold functions
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 08:54:35 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecabc6684f23: [OpenMP] Change analysis remarks to not emit on cold functions (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105196/new/
https://reviews.llvm.org/D105196
Files:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/single_threaded_execution.ll
Index: llvm/test/Transforms/OpenMP/single_threaded_execution.ll
===================================================================
--- llvm/test/Transforms/OpenMP/single_threaded_execution.ll
+++ llvm/test/Transforms/OpenMP/single_threaded_execution.ll
@@ -1,5 +1,5 @@
; RUN: opt -passes=openmp-opt -debug-only=openmp-opt -disable-output < %s 2>&1 | FileCheck %s
-; RUN: opt -passes=openmp-opt -pass-remarks-missed=openmp-opt -disable-output < %s 2>&1 | FileCheck %s --check-prefix=REMARKS
+; RUN: opt -passes=openmp-opt -pass-remarks-analysis=openmp-opt -disable-output < %s 2>&1 | FileCheck %s --check-prefix=REMARKS
; REQUIRES: asserts
; ModuleID = 'single_threaded_exeuction.c'
@@ -11,6 +11,7 @@
}
; REMARKS: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
+; REMARKS-NOT: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
; CHECK-NOT: [openmp-opt] Basic block @nvptx entry is executed by a single thread.
; CHECK: [openmp-opt] Basic block @nvptx if.then is executed by a single thread.
@@ -26,6 +27,7 @@
call void @foo()
call void @bar()
call void @baz()
+ call void @cold()
br label %if.end
if.end:
@@ -46,6 +48,7 @@
call void @foo()
call void @bar()
call void @baz()
+ call void @cold()
br label %if.end
if.end:
@@ -73,17 +76,25 @@
ret void
}
+; CHECK-NOT: [openmp-opt] Basic block @cold entry is executed by a single thread.
+; Function Attrs: cold convergent noinline nounwind optnone mustprogress
+define weak void @cold() #0 !dbg !9 {
+entry:
+ ret void
+}
+
declare i32 @llvm.nvvm.read.ptx.sreg.tid.x()
declare i32 @llvm.amdgcn.workitem.id.x()
declare void @__kmpc_kernel_init(i32, i16)
+attributes #0 = { cold noinline }
+
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!nvvm.annotations = !{!7}
-
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "single_threaded_execution.c", directory: "/tmp/single_threaded_execution.c")
!2 = !{}
@@ -92,6 +103,6 @@
!5 = !{i32 7, !"openmp", i32 50}
!6 = !{i32 7, !"openmp-device", i32 50}
!7 = !{void ()* @kernel, !"kernel", i32 1}
-!8 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
-!9 = !DISubroutineType(types: !2)
-!10 = !DILocation(line: 5, column: 7, scope: !8)
+!8 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!9 = distinct !DISubprogram(name: "cold", scope: !1, file: !1, line: 8, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !2)
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2650,8 +2650,8 @@
auto EmitRemark = [&](Function &F) {
auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
ORE.emit([&]() {
- OptimizationRemarkMissed ORM(DEBUG_TYPE, "InternalizationFailure", &F);
- return ORM << "Could not internalize function. "
+ OptimizationRemarkAnalysis ORA(DEBUG_TYPE, "InternalizationFailure", &F);
+ return ORA << "Could not internalize function. "
<< "Some optimizations may not be possible.";
});
};
@@ -2664,7 +2664,7 @@
if (!F.isDeclaration() && !Kernels.contains(&F) && IsCalled(F)) {
if (Attributor::internalizeFunction(F, /* Force */ true)) {
InternalizedFuncs.insert(&F);
- } else if (!F.hasLocalLinkage()) {
+ } else if (!F.hasLocalLinkage() && !F.hasFnAttribute(Attribute::Cold)) {
EmitRemark(F);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105196.355572.patch
Type: text/x-patch
Size: 4189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/98c55d4a/attachment.bin>
More information about the llvm-commits
mailing list