llvm.org GIT mirror llvm / 41b81eb
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291361 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 2 years ago
4 changed file(s) with 145 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
0 void bar(void);
1 void foo(int n) {
2 if (n) { bar(); } else { while (1) {} }
3 }
4
5 void quack(void) {
6 foo(0);
7 }
8
9 void quack2(void) {
10 foo(4);
11 }
12
0 --- !Missed
1 Pass: inline
2 Name: NoDefinition
3 DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 12 }
4 Function: foo
5 Args:
6 - Callee: bar
7 - String: ' will not be inlined into '
8 - Caller: foo
9 DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
10 - String: ' because its definition is unavailable'
11 ...
12 --- !Analysis
13 Pass: inline
14 Name: CanBeInlined
15 DebugLoc: { File: Inputs/dm.c, Line: 7, Column: 3 }
16 Function: quack
17 Args:
18 - Callee: foo
19 DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
20 - String: ' can be inlined into '
21 - Caller: quack
22 DebugLoc: { File: Inputs/dm.c, Line: 6, Column: 0 }
23 - String: ' with cost='
24 - Cost: '-35'
25 - String: ' (threshold='
26 - Threshold: '375'
27 - String: ')'
28 ...
29 --- !Passed
30 Pass: inline
31 Name: Inlined
32 DebugLoc: { File: Inputs/dm.c, Line: 7, Column: 3 }
33 Function: quack
34 Args:
35 - Callee: foo
36 DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
37 - String: ' inlined into '
38 - Caller: quack
39 DebugLoc: { File: Inputs/dm.c, Line: 6, Column: 0 }
40 ...
41 --- !Analysis
42 Pass: inline
43 Name: CanBeInlined
44 DebugLoc: { File: Inputs/dm.c, Line: 11, Column: 3 }
45 Function: quack2
46 Args:
47 - Callee: foo
48 DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
49 - String: ' can be inlined into '
50 - Caller: quack2
51 DebugLoc: { File: Inputs/dm.c, Line: 10, Column: 0 }
52 - String: ' with cost='
53 - Cost: '-5'
54 - String: ' (threshold='
55 - Threshold: '375'
56 - String: ')'
57 ...
58 --- !Passed
59 Pass: inline
60 Name: Inlined
61 DebugLoc: { File: Inputs/dm.c, Line: 11, Column: 3 }
62 Function: quack2
63 Args:
64 - Callee: foo
65 DebugLoc: { File: Inputs/dm.c, Line: 2, Column: 0 }
66 - String: ' inlined into '
67 - Caller: quack2
68 DebugLoc: { File: Inputs/dm.c, Line: 10, Column: 0 }
69 ...
70 --- !Analysis
71 Pass: loop-vectorize
72 Name: CFGNotUnderstood
73 DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
74 Function: foo
75 Args:
76 - String: 'loop not vectorized: '
77 - String: loop control flow is not understood by vectorizer
78 ...
79 --- !Missed
80 Pass: loop-vectorize
81 Name: MissedDetails
82 DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
83 Function: foo
84 Args:
85 - String: loop not vectorized
86 ...
87 --- !Analysis
88 Pass: loop-vectorize
89 Name: CFGNotUnderstood
90 DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
91 Function: quack
92 Args:
93 - String: 'loop not vectorized: '
94 - String: loop control flow is not understood by vectorizer
95 ...
96 --- !Missed
97 Pass: loop-vectorize
98 Name: MissedDetails
99 DebugLoc: { File: Inputs/dm.c, Line: 3, Column: 28 }
100 Function: quack
101 Args:
102 - String: loop not vectorized
103 ...
0 RUN: llvm-opt-report -r %p %p/Inputs/dm.yaml | FileCheck -strict-whitespace %s
1
2 ; CHECK: < {{.*[/\]}}dm.c
3 ; CHECK-NEXT: 1 | void bar(void);
4 ; CHECK-NEXT: 2 | void foo(int n) {
5 ; CHECK-NEXT: 3 | if (n) { bar(); } else { while (1) {} }
6 ; CHECK-NEXT: 4 | }
7 ; CHECK-NEXT: 5 |
8 ; CHECK-NEXT: 6 | void quack(void) {
9 ; CHECK-NEXT: 7 I | foo(0);
10 ; CHECK-NEXT: 8 | }
11 ; CHECK-NEXT: 9 |
12 ; CHECK-NEXT: 10 | void quack2(void) {
13 ; CHECK-NEXT: 11 I | foo(4);
14 ; CHECK-NEXT: 12 | }
15 ; CHECK-NEXT: 13 |
16
357357 std::map ColsInfo;
358358 unsigned InlinedCols = 0, UnrolledCols = 0, VectorizedCols = 0;
359359
360 if (LII != FileInfo.end()) {
360 if (LII != FileInfo.end() && !FuncNameSet.empty()) {
361361 const auto &LineInfo = LII->second;
362362
363363 for (auto &CI : LineInfo.find(*FuncNameSet.begin())->second) {
474474 std::map,
475475 std::set> UniqueLIs;
476476
477 OptReportLocationInfo AllLI;
477478 if (LII != FileInfo.end()) {
478479 const auto &FuncLineInfo = LII->second;
479 for (const auto &FLII : FuncLineInfo)
480 for (const auto &FLII : FuncLineInfo) {
480481 UniqueLIs[FLII.second].insert(FLII.first);
482
483 for (const auto &OI : FLII.second)
484 AllLI |= OI.second;
485 }
481486 }
482487
483 if (UniqueLIs.size() > 1) {
488 bool NothingHappened = !AllLI.Inlined.Transformed &&
489 !AllLI.Unrolled.Transformed &&
490 !AllLI.Vectorized.Transformed;
491 if (UniqueLIs.size() > 1 && !NothingHappened) {
484492 OS << " [[\n";
485493 for (const auto &FSLI : UniqueLIs)
486494 PrintLine(true, FSLI.second);