From e1cb0bd2ab4427f2f7e19b0d958eff5f553e2214 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sat, 8 Oct 2016 00:26:54 +0000 Subject: [PATCH] [llvm-opt-report] Don't leave space for opts that never happen Because screen space is precious, if an optimization (vectorization, for example) never happens, don't leave empty space for the associated markers on every line of the output. This makes the output much more compact, and allows for the later inclusion of markers for more (although perhaps rare) optimizations. llvm-svn: 283626 --- test/tools/llvm-opt-report/func-2.test | 68 +++++++++--------- test/tools/llvm-opt-report/func-x.test | 90 ++++++++++++------------ test/tools/llvm-opt-report/func.test | 60 ++++++++-------- test/tools/llvm-opt-report/mlineopt.test | 70 +++++++++--------- test/tools/llvm-opt-report/unrl.test | 20 +++--- tools/llvm-opt-report/OptReport.cpp | 19 +++-- 6 files changed, 167 insertions(+), 160 deletions(-) diff --git a/test/tools/llvm-opt-report/func-2.test b/test/tools/llvm-opt-report/func-2.test index d1c5e7da354..905b9890ad5 100644 --- a/test/tools/llvm-opt-report/func-2.test +++ b/test/tools/llvm-opt-report/func-2.test @@ -2,48 +2,48 @@ RUN: llvm-opt-report -r %p %p/Inputs/q2.yaml | FileCheck -strict-whitespace %s RUN: llvm-opt-report -s -r %p %p/Inputs/q2.yaml | FileCheck -strict-whitespace -check-prefix=CHECK-SUCCINCT %s ; CHECK: < {{.*[/\]}}q2.c -; CHECK-NEXT: 1 | void bar(); -; CHECK-NEXT: 2 | void foo(int n) { +; CHECK-NEXT: 1 | void bar(); +; CHECK-NEXT: 2 | void foo(int n) { ; CHECK-NEXT: {{\[\[}} ; CHECK-NEXT: > quack, quack2: -; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) -; CHECK-NEXT: U4 | ^ -; CHECK-NEXT: U4 | ^ +; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) +; CHECK-NEXT: U4 | ^ +; CHECK-NEXT: U4 | ^ ; CHECK-NEXT: > foo: -; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) +; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) ; CHECK-NEXT: {{\]\]}} -; CHECK-NEXT: 4 | bar(); -; CHECK-NEXT: 5 | } -; CHECK-NEXT: 6 | -; CHECK-NEXT: 7 | void quack() { -; CHECK-NEXT: 8 I | foo(4); -; CHECK-NEXT: 9 | } -; CHECK-NEXT: 10 | -; CHECK-NEXT: 11 | void quack2() { -; CHECK-NEXT: 12 I | foo(4); -; CHECK-NEXT: 13 | } -; CHECK-NEXT: 14 | +; CHECK-NEXT: 4 | bar(); +; CHECK-NEXT: 5 | } +; CHECK-NEXT: 6 | +; CHECK-NEXT: 7 | void quack() { +; CHECK-NEXT: 8 I | foo(4); +; CHECK-NEXT: 9 | } +; CHECK-NEXT: 10 | +; CHECK-NEXT: 11 | void quack2() { +; CHECK-NEXT: 12 I | foo(4); +; CHECK-NEXT: 13 | } +; CHECK-NEXT: 14 | ; CHECK-SUCCINCT: < {{.*[/\]}}q2.c -; CHECK-SUCCINCT-NEXT: 1 | void bar(); -; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { +; CHECK-SUCCINCT-NEXT: 1 | void bar(); +; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { ; CHECK-SUCCINCT-NEXT: {{\[\[}} ; CHECK-SUCCINCT-NEXT: > quack, quack2: -; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) -; CHECK-SUCCINCT-NEXT: U | ^ -; CHECK-SUCCINCT-NEXT: U | ^ +; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) +; CHECK-SUCCINCT-NEXT: U | ^ +; CHECK-SUCCINCT-NEXT: U | ^ ; CHECK-SUCCINCT-NEXT: > foo: -; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) +; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) ; CHECK-SUCCINCT-NEXT: {{\]\]}} -; CHECK-SUCCINCT-NEXT: 4 | bar(); -; CHECK-SUCCINCT-NEXT: 5 | } -; CHECK-SUCCINCT-NEXT: 6 | -; CHECK-SUCCINCT-NEXT: 7 | void quack() { -; CHECK-SUCCINCT-NEXT: 8 I | foo(4); -; CHECK-SUCCINCT-NEXT: 9 | } -; CHECK-SUCCINCT-NEXT: 10 | -; CHECK-SUCCINCT-NEXT: 11 | void quack2() { -; CHECK-SUCCINCT-NEXT: 12 I | foo(4); -; CHECK-SUCCINCT-NEXT: 13 | } -; CHECK-SUCCINCT-NEXT: 14 | +; CHECK-SUCCINCT-NEXT: 4 | bar(); +; CHECK-SUCCINCT-NEXT: 5 | } +; CHECK-SUCCINCT-NEXT: 6 | +; CHECK-SUCCINCT-NEXT: 7 | void quack() { +; CHECK-SUCCINCT-NEXT: 8 I | foo(4); +; CHECK-SUCCINCT-NEXT: 9 | } +; CHECK-SUCCINCT-NEXT: 10 | +; CHECK-SUCCINCT-NEXT: 11 | void quack2() { +; CHECK-SUCCINCT-NEXT: 12 I | foo(4); +; CHECK-SUCCINCT-NEXT: 13 | } +; CHECK-SUCCINCT-NEXT: 14 | diff --git a/test/tools/llvm-opt-report/func-x.test b/test/tools/llvm-opt-report/func-x.test index a697a589d27..9c8f9c0e9ff 100644 --- a/test/tools/llvm-opt-report/func-x.test +++ b/test/tools/llvm-opt-report/func-x.test @@ -3,65 +3,65 @@ RUN: llvm-opt-report -no-demangle -r %p %p/Inputs/qx.yaml | FileCheck -strict-wh RUN: llvm-opt-report -s -r %p %p/Inputs/qx.yaml | FileCheck -strict-whitespace -check-prefix=CHECK-SUCCINCT %s ; CHECK: < {{.*[/\]}}q.cpp -; CHECK-NEXT: 1 | void bar(); -; CHECK-NEXT: 2 | void foo(int n) { +; CHECK-NEXT: 1 | void bar(); +; CHECK-NEXT: 2 | void foo(int n) { ; CHECK-NEXT: {{\[\[}} ; CHECK-NEXT: > foo(int): -; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) +; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) ; CHECK-NEXT: > quack(), quack2(): -; CHECK-NEXT: 3 U4 | for (int i = 0; i < n; ++i) +; CHECK-NEXT: 3 U4 | for (int i = 0; i < n; ++i) ; CHECK-NEXT: {{\]\]}} -; CHECK-NEXT: 4 | bar(); -; CHECK-NEXT: 5 | } -; CHECK-NEXT: 6 | -; CHECK-NEXT: 7 | void quack() { -; CHECK-NEXT: 8 I | foo(4); -; CHECK-NEXT: 9 | } -; CHECK-NEXT: 10 | -; CHECK-NEXT: 11 | void quack2() { -; CHECK-NEXT: 12 I | foo(4); -; CHECK-NEXT: 13 | } -; CHECK-NEXT: 14 | +; CHECK-NEXT: 4 | bar(); +; CHECK-NEXT: 5 | } +; CHECK-NEXT: 6 | +; CHECK-NEXT: 7 | void quack() { +; CHECK-NEXT: 8 I | foo(4); +; CHECK-NEXT: 9 | } +; CHECK-NEXT: 10 | +; CHECK-NEXT: 11 | void quack2() { +; CHECK-NEXT: 12 I | foo(4); +; CHECK-NEXT: 13 | } +; CHECK-NEXT: 14 | ; CHECK-NODEM: < {{.*[/\]}}q.cpp -; CHECK-NODEM-NEXT: 1 | void bar(); -; CHECK-NODEM-NEXT: 2 | void foo(int n) { +; CHECK-NODEM-NEXT: 1 | void bar(); +; CHECK-NODEM-NEXT: 2 | void foo(int n) { ; CHECK-NODEM-NEXT: {{\[\[}} ; CHECK-NODEM-NEXT: > _Z3fooi: -; CHECK-NODEM-NEXT: 3 | for (int i = 0; i < n; ++i) +; CHECK-NODEM-NEXT: 3 | for (int i = 0; i < n; ++i) ; CHECK-NODEM-NEXT: > _Z5quackv, _Z6quack2v: -; CHECK-NODEM-NEXT: 3 U4 | for (int i = 0; i < n; ++i) +; CHECK-NODEM-NEXT: 3 U4 | for (int i = 0; i < n; ++i) ; CHECK-NODEM-NEXT: {{\]\]}} -; CHECK-NODEM-NEXT: 4 | bar(); -; CHECK-NODEM-NEXT: 5 | } -; CHECK-NODEM-NEXT: 6 | -; CHECK-NODEM-NEXT: 7 | void quack() { -; CHECK-NODEM-NEXT: 8 I | foo(4); -; CHECK-NODEM-NEXT: 9 | } -; CHECK-NODEM-NEXT: 10 | -; CHECK-NODEM-NEXT: 11 | void quack2() { -; CHECK-NODEM-NEXT: 12 I | foo(4); -; CHECK-NODEM-NEXT: 13 | } -; CHECK-NODEM-NEXT: 14 | +; CHECK-NODEM-NEXT: 4 | bar(); +; CHECK-NODEM-NEXT: 5 | } +; CHECK-NODEM-NEXT: 6 | +; CHECK-NODEM-NEXT: 7 | void quack() { +; CHECK-NODEM-NEXT: 8 I | foo(4); +; CHECK-NODEM-NEXT: 9 | } +; CHECK-NODEM-NEXT: 10 | +; CHECK-NODEM-NEXT: 11 | void quack2() { +; CHECK-NODEM-NEXT: 12 I | foo(4); +; CHECK-NODEM-NEXT: 13 | } +; CHECK-NODEM-NEXT: 14 | ; CHECK-SUCCINCT: < {{.*[/\]}}q.cpp -; CHECK-SUCCINCT-NEXT: 1 | void bar(); -; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { +; CHECK-SUCCINCT-NEXT: 1 | void bar(); +; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { ; CHECK-SUCCINCT-NEXT: {{\[\[}} ; CHECK-SUCCINCT-NEXT: > foo(int): -; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) +; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) ; CHECK-SUCCINCT-NEXT: > quack(), quack2(): -; CHECK-SUCCINCT-NEXT: 3 U | for (int i = 0; i < n; ++i) +; CHECK-SUCCINCT-NEXT: 3 U | for (int i = 0; i < n; ++i) ; CHECK-SUCCINCT-NEXT: {{\]\]}} -; CHECK-SUCCINCT-NEXT: 4 | bar(); -; CHECK-SUCCINCT-NEXT: 5 | } -; CHECK-SUCCINCT-NEXT: 6 | -; CHECK-SUCCINCT-NEXT: 7 | void quack() { -; CHECK-SUCCINCT-NEXT: 8 I | foo(4); -; CHECK-SUCCINCT-NEXT: 9 | } -; CHECK-SUCCINCT-NEXT: 10 | -; CHECK-SUCCINCT-NEXT: 11 | void quack2() { -; CHECK-SUCCINCT-NEXT: 12 I | foo(4); -; CHECK-SUCCINCT-NEXT: 13 | } -; CHECK-SUCCINCT-NEXT: 14 | +; CHECK-SUCCINCT-NEXT: 4 | bar(); +; CHECK-SUCCINCT-NEXT: 5 | } +; CHECK-SUCCINCT-NEXT: 6 | +; CHECK-SUCCINCT-NEXT: 7 | void quack() { +; CHECK-SUCCINCT-NEXT: 8 I | foo(4); +; CHECK-SUCCINCT-NEXT: 9 | } +; CHECK-SUCCINCT-NEXT: 10 | +; CHECK-SUCCINCT-NEXT: 11 | void quack2() { +; CHECK-SUCCINCT-NEXT: 12 I | foo(4); +; CHECK-SUCCINCT-NEXT: 13 | } +; CHECK-SUCCINCT-NEXT: 14 | diff --git a/test/tools/llvm-opt-report/func.test b/test/tools/llvm-opt-report/func.test index 4b944d96a71..f183594d98f 100644 --- a/test/tools/llvm-opt-report/func.test +++ b/test/tools/llvm-opt-report/func.test @@ -2,44 +2,44 @@ RUN: llvm-opt-report -r %p %p/Inputs/q.yaml | FileCheck -strict-whitespace %s RUN: llvm-opt-report -s -r %p %p/Inputs/q.yaml | FileCheck -strict-whitespace -check-prefix=CHECK-SUCCINCT %s ; CHECK: < {{.*[/\]}}q.c -; CHECK-NEXT: 1 | void bar(); -; CHECK-NEXT: 2 | void foo(int n) { +; CHECK-NEXT: 1 | void bar(); +; CHECK-NEXT: 2 | void foo(int n) { ; CHECK-NEXT: {{\[\[}} ; CHECK-NEXT: > foo: -; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) +; CHECK-NEXT: 3 | for (int i = 0; i < n; ++i) ; CHECK-NEXT: > quack, quack2: -; CHECK-NEXT: 3 U4 | for (int i = 0; i < n; ++i) +; CHECK-NEXT: 3 U4 | for (int i = 0; i < n; ++i) ; CHECK-NEXT: {{\]\]}} -; CHECK-NEXT: 4 | bar(); -; CHECK-NEXT: 5 | } -; CHECK-NEXT: 6 | -; CHECK-NEXT: 7 | void quack() { -; CHECK-NEXT: 8 I | foo(4); -; CHECK-NEXT: 9 | } -; CHECK-NEXT: 10 | -; CHECK-NEXT: 11 | void quack2() { -; CHECK-NEXT: 12 I | foo(4); -; CHECK-NEXT: 13 | } -; CHECK-NEXT: 14 | +; CHECK-NEXT: 4 | bar(); +; CHECK-NEXT: 5 | } +; CHECK-NEXT: 6 | +; CHECK-NEXT: 7 | void quack() { +; CHECK-NEXT: 8 I | foo(4); +; CHECK-NEXT: 9 | } +; CHECK-NEXT: 10 | +; CHECK-NEXT: 11 | void quack2() { +; CHECK-NEXT: 12 I | foo(4); +; CHECK-NEXT: 13 | } +; CHECK-NEXT: 14 | ; CHECK-SUCCINCT: < {{.*[/\]}}q.c -; CHECK-SUCCINCT-NEXT: 1 | void bar(); -; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { +; CHECK-SUCCINCT-NEXT: 1 | void bar(); +; CHECK-SUCCINCT-NEXT: 2 | void foo(int n) { ; CHECK-SUCCINCT-NEXT: {{\[\[}} ; CHECK-SUCCINCT-NEXT: > foo: -; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) +; CHECK-SUCCINCT-NEXT: 3 | for (int i = 0; i < n; ++i) ; CHECK-SUCCINCT-NEXT: > quack, quack2: -; CHECK-SUCCINCT-NEXT: 3 U | for (int i = 0; i < n; ++i) +; CHECK-SUCCINCT-NEXT: 3 U | for (int i = 0; i < n; ++i) ; CHECK-SUCCINCT-NEXT: {{\]\]}} -; CHECK-SUCCINCT-NEXT: 4 | bar(); -; CHECK-SUCCINCT-NEXT: 5 | } -; CHECK-SUCCINCT-NEXT: 6 | -; CHECK-SUCCINCT-NEXT: 7 | void quack() { -; CHECK-SUCCINCT-NEXT: 8 I | foo(4); -; CHECK-SUCCINCT-NEXT: 9 | } -; CHECK-SUCCINCT-NEXT: 10 | -; CHECK-SUCCINCT-NEXT: 11 | void quack2() { -; CHECK-SUCCINCT-NEXT: 12 I | foo(4); -; CHECK-SUCCINCT-NEXT: 13 | } -; CHECK-SUCCINCT-NEXT: 14 | +; CHECK-SUCCINCT-NEXT: 4 | bar(); +; CHECK-SUCCINCT-NEXT: 5 | } +; CHECK-SUCCINCT-NEXT: 6 | +; CHECK-SUCCINCT-NEXT: 7 | void quack() { +; CHECK-SUCCINCT-NEXT: 8 I | foo(4); +; CHECK-SUCCINCT-NEXT: 9 | } +; CHECK-SUCCINCT-NEXT: 10 | +; CHECK-SUCCINCT-NEXT: 11 | void quack2() { +; CHECK-SUCCINCT-NEXT: 12 I | foo(4); +; CHECK-SUCCINCT-NEXT: 13 | } +; CHECK-SUCCINCT-NEXT: 14 | diff --git a/test/tools/llvm-opt-report/mlineopt.test b/test/tools/llvm-opt-report/mlineopt.test index 808380dead5..a69455abb7a 100644 --- a/test/tools/llvm-opt-report/mlineopt.test +++ b/test/tools/llvm-opt-report/mlineopt.test @@ -1,39 +1,39 @@ RUN: llvm-opt-report -r %p %p/Inputs/sr2.yaml | FileCheck -strict-whitespace %s ; CHECK: < {{.*[/\]}}sr2.c -; CHECK-NEXT: 1 | /* -; CHECK-NEXT: 2 | ** Write a 64-bit variable-length integer to memory starting at p[0]. -; CHECK-NEXT: 3 | ** The length of data write will be between 1 and 9 bytes. The number -; CHECK-NEXT: 4 | ** of bytes written is returned. -; CHECK-NEXT: 5 | ** -; CHECK-NEXT: 6 | ** A variable-length integer consists of the lower 7 bits of each byte -; CHECK-NEXT: 7 | ** for all bytes that have the 8th bit set and one byte with the 8th -; CHECK-NEXT: 8 | ** bit clear. Except, if we get to the 9th byte, it stores the full -; CHECK-NEXT: 9 | ** 8 bits and is the last byte. -; CHECK-NEXT: 10 | */ -; CHECK-NEXT: 11 | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){ -; CHECK-NEXT: 12 | int i, j, n; -; CHECK-NEXT: 13 | u8 buf[10]; -; CHECK-NEXT: 14 | if( v & (((u64)0xff000000)<<32) ){ -; CHECK-NEXT: 15 | p[8] = v; -; CHECK-NEXT: 16 | v >>= 8; -; CHECK-NEXT: 17 | for(i=7; i>=0; i--){ -; CHECK-NEXT: 18 | p[i] = (v & 0x7f) | 0x80; -; CHECK-NEXT: 19 | v >>= 7; -; CHECK-NEXT: 20 | } -; CHECK-NEXT: 21 | return 9; -; CHECK-NEXT: 22 | } -; CHECK-NEXT: 23 | n = 0; -; CHECK-NEXT: 24 | do{ -; CHECK-NEXT: 25 | buf[n++] = (v & 0x7f) | 0x80; -; CHECK-NEXT: 26 | v >>= 7; -; CHECK-NEXT: 27 | }while( v!=0 ); -; CHECK-NEXT: 28 | buf[0] &= 0x7f; -; CHECK-NEXT: 29 | assert( n<=9 ); -; CHECK-NEXT: 30 U2V16,2 | for(i=0, j=n-1; j>=0; j--, i++){ -; CHECK-NEXT: 31 | p[i] = buf[j]; -; CHECK-NEXT: 32 | } -; CHECK-NEXT: 33 | return n; -; CHECK-NEXT: 34 | } -; CHECK-NEXT: 35 | +; CHECK-NEXT: 1 | /* +; CHECK-NEXT: 2 | ** Write a 64-bit variable-length integer to memory starting at p[0]. +; CHECK-NEXT: 3 | ** The length of data write will be between 1 and 9 bytes. The number +; CHECK-NEXT: 4 | ** of bytes written is returned. +; CHECK-NEXT: 5 | ** +; CHECK-NEXT: 6 | ** A variable-length integer consists of the lower 7 bits of each byte +; CHECK-NEXT: 7 | ** for all bytes that have the 8th bit set and one byte with the 8th +; CHECK-NEXT: 8 | ** bit clear. Except, if we get to the 9th byte, it stores the full +; CHECK-NEXT: 9 | ** 8 bits and is the last byte. +; CHECK-NEXT: 10 | */ +; CHECK-NEXT: 11 | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){ +; CHECK-NEXT: 12 | int i, j, n; +; CHECK-NEXT: 13 | u8 buf[10]; +; CHECK-NEXT: 14 | if( v & (((u64)0xff000000)<<32) ){ +; CHECK-NEXT: 15 | p[8] = v; +; CHECK-NEXT: 16 | v >>= 8; +; CHECK-NEXT: 17 | for(i=7; i>=0; i--){ +; CHECK-NEXT: 18 | p[i] = (v & 0x7f) | 0x80; +; CHECK-NEXT: 19 | v >>= 7; +; CHECK-NEXT: 20 | } +; CHECK-NEXT: 21 | return 9; +; CHECK-NEXT: 22 | } +; CHECK-NEXT: 23 | n = 0; +; CHECK-NEXT: 24 | do{ +; CHECK-NEXT: 25 | buf[n++] = (v & 0x7f) | 0x80; +; CHECK-NEXT: 26 | v >>= 7; +; CHECK-NEXT: 27 | }while( v!=0 ); +; CHECK-NEXT: 28 | buf[0] &= 0x7f; +; CHECK-NEXT: 29 | assert( n<=9 ); +; CHECK-NEXT: 30 U2V16,2 | for(i=0, j=n-1; j>=0; j--, i++){ +; CHECK-NEXT: 31 | p[i] = buf[j]; +; CHECK-NEXT: 32 | } +; CHECK-NEXT: 33 | return n; +; CHECK-NEXT: 34 | } +; CHECK-NEXT: 35 | diff --git a/test/tools/llvm-opt-report/unrl.test b/test/tools/llvm-opt-report/unrl.test index 3232d18effc..48bfeec6f40 100644 --- a/test/tools/llvm-opt-report/unrl.test +++ b/test/tools/llvm-opt-report/unrl.test @@ -1,14 +1,14 @@ RUN: llvm-opt-report -r %p %p/Inputs/unrl.yaml | FileCheck -strict-whitespace %s ; CHECK: < {{.*[/\]}}unrl.c -; CHECK-NEXT: 1 | void bar(); -; CHECK-NEXT: 2 | -; CHECK-NEXT: 3 | void foo() { -; CHECK-NEXT: 4 U5 | for (int i = 0; i < 5; ++i) -; CHECK-NEXT: 5 | bar(); -; CHECK-NEXT: 6 | -; CHECK-NEXT: 7 U11 | for (int i = 0; i < 11; ++i) -; CHECK-NEXT: 8 | bar(); -; CHECK-NEXT: 9 | } -; CHECK-NEXT: 10 | +; CHECK-NEXT: 1 | void bar(); +; CHECK-NEXT: 2 | +; CHECK-NEXT: 3 | void foo() { +; CHECK-NEXT: 4 U5 | for (int i = 0; i < 5; ++i) +; CHECK-NEXT: 5 | bar(); +; CHECK-NEXT: 6 | +; CHECK-NEXT: 7 U11 | for (int i = 0; i < 11; ++i) +; CHECK-NEXT: 8 | bar(); +; CHECK-NEXT: 9 | } +; CHECK-NEXT: 10 | diff --git a/tools/llvm-opt-report/OptReport.cpp b/tools/llvm-opt-report/OptReport.cpp index b82a73b6d94..0f0faa832bd 100644 --- a/tools/llvm-opt-report/OptReport.cpp +++ b/tools/llvm-opt-report/OptReport.cpp @@ -332,6 +332,10 @@ static bool writeReport(LocationInfoTy &LocationInfo) { for (auto &LI : FI.second) MaxLI |= LI.second; + bool NothingInlined = !MaxLI.Inlined.Transformed; + bool NothingUnrolled = !MaxLI.Unrolled.Transformed; + bool NothingVectorized = !MaxLI.Vectorized.Transformed; + unsigned VFDigits = llvm::utostr(MaxLI.VectorizationFactor).size(); unsigned ICDigits = llvm::utostr(MaxLI.InterleaveCount).size(); unsigned UCDigits = llvm::utostr(MaxLI.UnrollCount).size(); @@ -435,11 +439,12 @@ static bool writeReport(LocationInfoTy &LocationInfo) { }; OS << llvm::format_decimal(L, LNDigits) << " "; - OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : " "); + OS << (LLI.Inlined.Transformed && InlinedCols < 2 ? "I" : + (NothingInlined ? "" : " ")); OS << (LLI.Unrolled.Transformed && UnrolledCols < 2 ? - "U" + UStr(LLI) : " " + USpaces); + "U" + UStr(LLI) : (NothingUnrolled ? "" : " " + USpaces)); OS << (LLI.Vectorized.Transformed && VectorizedCols < 2 ? - "V" + VStr(LLI) : " " + VSpaces); + "V" + VStr(LLI) : (NothingVectorized ? "" : " " + VSpaces)); OS << " | " << *LI << "\n"; @@ -449,11 +454,13 @@ static bool writeReport(LocationInfoTy &LocationInfo) { (J.second.Vectorized.Transformed && VectorizedCols > 1)) { OS << std::string(LNDigits + 1, ' '); OS << (J.second.Inlined.Transformed && - InlinedCols > 1 ? "I" : " "); + InlinedCols > 1 ? "I" : (NothingInlined ? "" : " ")); OS << (J.second.Unrolled.Transformed && - UnrolledCols > 1 ? "U" + UStr(J.second) : " " + USpaces); + UnrolledCols > 1 ? "U" + UStr(J.second) : + (NothingUnrolled ? "" : " " + USpaces)); OS << (J.second.Vectorized.Transformed && - VectorizedCols > 1 ? "V" + VStr(J.second) : " " + VSpaces); + VectorizedCols > 1 ? "V" + VStr(J.second) : + (NothingVectorized ? "" : " " + VSpaces)); OS << " | " << std::string(J.first - 1, ' ') << "^\n"; }