[llvm] r291361 - [llvm-opt-report] Fix context-sensitive lines where nothing happened
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 7 12:21:17 PST 2017
Author: hfinkel
Date: Sat Jan 7 14:21:17 2017
New Revision: 291361
URL: http://llvm.org/viewvc/llvm-project?rev=291361&view=rev
Log:
[llvm-opt-report] Fix context-sensitive lines where nothing happened
Don't print a line multiple times, each for different inlining contexts, if
nothing happened in any context. This prevents situations like this:
[[
> main:
65 | if ((i * ni + j) % 20 == 0) fprintf
> print_array:
65 | if ((i * ni + j) % 20 == 0) fprintf
]]
which could happen if different optimizations were missed in different inlining
contexts.
Added:
llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.c
llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.yaml
llvm/trunk/test/tools/llvm-opt-report/func-dm.test
Modified:
llvm/trunk/tools/llvm-opt-report/OptReport.cpp
Added: llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.c?rev=291361&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.c (added)
+++ llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.c Sat Jan 7 14:21:17 2017
@@ -0,0 +1,13 @@
+void bar(void);
+void foo(int n) {
+ if (n) { bar(); } else { while (1) {} }
+}
+
+void quack(void) {
+ foo(0);
+}
+
+void quack2(void) {
+ foo(4);
+}
+
Added: llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.yaml?rev=291361&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.yaml (added)
+++ llvm/trunk/test/tools/llvm-opt-report/Inputs/dm.yaml Sat Jan 7 14:21:17 2017
@@ -0,0 +1,104 @@
+--- !Missed
+Pass: inline
+Name: NoDefinition
+DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 12 }
+Function: foo
+Args:
+ - Callee: bar
+ - String: ' will not be inlined into '
+ - Caller: foo
+ DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
+ - String: ' because its definition is unavailable'
+...
+--- !Analysis
+Pass: inline
+Name: CanBeInlined
+DebugLoc: { File: Inputs/dm.c, Line: 7, Column: 3 }
+Function: quack
+Args:
+ - Callee: foo
+ DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
+ - String: ' can be inlined into '
+ - Caller: quack
+ DebugLoc: { File: Inputs/dm.c, Line: 6, Column: 0 }
+ - String: ' with cost='
+ - Cost: '-35'
+ - String: ' (threshold='
+ - Threshold: '375'
+ - String: ')'
+...
+--- !Passed
+Pass: inline
+Name: Inlined
+DebugLoc: { File: Inputs/dm.c, Line: 7, Column: 3 }
+Function: quack
+Args:
+ - Callee: foo
+ DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
+ - String: ' inlined into '
+ - Caller: quack
+ DebugLoc: { File: Inputs/dm.c, Line: 6, Column: 0 }
+...
+--- !Analysis
+Pass: inline
+Name: CanBeInlined
+DebugLoc: { File: Inputs/dm.c, Line: 11, Column: 3 }
+Function: quack2
+Args:
+ - Callee: foo
+ DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
+ - String: ' can be inlined into '
+ - Caller: quack2
+ DebugLoc: { File: Inputs/dm.c, Line: 10, Column: 0 }
+ - String: ' with cost='
+ - Cost: '-5'
+ - String: ' (threshold='
+ - Threshold: '375'
+ - String: ')'
+...
+--- !Passed
+Pass: inline
+Name: Inlined
+DebugLoc: { File: Inputs/dm.c, Line: 11, Column: 3 }
+Function: quack2
+Args:
+ - Callee: foo
+ DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
+ - String: ' inlined into '
+ - Caller: quack2
+ DebugLoc: { File: Inputs/dm.c, Line: 10, Column: 0 }
+...
+--- !Analysis
+Pass: loop-vectorize
+Name: CFGNotUnderstood
+DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
+Function: foo
+Args:
+ - String: 'loop not vectorized: '
+ - String: loop control flow is not understood by vectorizer
+...
+--- !Missed
+Pass: loop-vectorize
+Name: MissedDetails
+DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
+Function: foo
+Args:
+ - String: loop not vectorized
+...
+--- !Analysis
+Pass: loop-vectorize
+Name: CFGNotUnderstood
+DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
+Function: quack
+Args:
+ - String: 'loop not vectorized: '
+ - String: loop control flow is not understood by vectorizer
+...
+--- !Missed
+Pass: loop-vectorize
+Name: MissedDetails
+DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
+Function: quack
+Args:
+ - String: loop not vectorized
+...
Added: llvm/trunk/test/tools/llvm-opt-report/func-dm.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-opt-report/func-dm.test?rev=291361&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-opt-report/func-dm.test (added)
+++ llvm/trunk/test/tools/llvm-opt-report/func-dm.test Sat Jan 7 14:21:17 2017
@@ -0,0 +1,17 @@
+RUN: llvm-opt-report -r %p %p/Inputs/dm.yaml | FileCheck -strict-whitespace %s
+
+; CHECK: < {{.*[/\]}}dm.c
+; CHECK-NEXT: 1 | void bar(void);
+; CHECK-NEXT: 2 | void foo(int n) {
+; CHECK-NEXT: 3 | if (n) { bar(); } else { while (1) {} }
+; CHECK-NEXT: 4 | }
+; CHECK-NEXT: 5 |
+; CHECK-NEXT: 6 | void quack(void) {
+; CHECK-NEXT: 7 I | foo(0);
+; CHECK-NEXT: 8 | }
+; CHECK-NEXT: 9 |
+; CHECK-NEXT: 10 | void quack2(void) {
+; CHECK-NEXT: 11 I | foo(4);
+; CHECK-NEXT: 12 | }
+; CHECK-NEXT: 13 |
+
Modified: llvm/trunk/tools/llvm-opt-report/OptReport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-opt-report/OptReport.cpp?rev=291361&r1=291360&r2=291361&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-opt-report/OptReport.cpp (original)
+++ llvm/trunk/tools/llvm-opt-report/OptReport.cpp Sat Jan 7 14:21:17 2017
@@ -358,7 +358,7 @@ static bool writeReport(LocationInfoTy &
std::map<int, OptReportLocationInfo> ColsInfo;
unsigned InlinedCols = 0, UnrolledCols = 0, VectorizedCols = 0;
- if (LII != FileInfo.end()) {
+ if (LII != FileInfo.end() && !FuncNameSet.empty()) {
const auto &LineInfo = LII->second;
for (auto &CI : LineInfo.find(*FuncNameSet.begin())->second) {
@@ -475,13 +475,21 @@ static bool writeReport(LocationInfoTy &
std::map<std::map<int, OptReportLocationInfo>,
std::set<std::string>> UniqueLIs;
+ OptReportLocationInfo AllLI;
if (LII != FileInfo.end()) {
const auto &FuncLineInfo = LII->second;
- for (const auto &FLII : FuncLineInfo)
+ for (const auto &FLII : FuncLineInfo) {
UniqueLIs[FLII.second].insert(FLII.first);
+
+ for (const auto &OI : FLII.second)
+ AllLI |= OI.second;
+ }
}
- if (UniqueLIs.size() > 1) {
+ bool NothingHappened = !AllLI.Inlined.Transformed &&
+ !AllLI.Unrolled.Transformed &&
+ !AllLI.Vectorized.Transformed;
+ if (UniqueLIs.size() > 1 && !NothingHappened) {
OS << " [[\n";
for (const auto &FSLI : UniqueLIs)
PrintLine(true, FSLI.second);
More information about the llvm-commits
mailing list