OSDN Git Service

[llvm-opt-report] Distinguish inlined contexts when optimizations differ
authorHal Finkel <hfinkel@anl.gov>
Wed, 5 Oct 2016 22:25:33 +0000 (22:25 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 5 Oct 2016 22:25:33 +0000 (22:25 +0000)
commit0837bf4c5118a4c26d1c3f0b2332445896b1c770
treee579d044cfe93955542ce11d307e729b0ee1f8c2
parent3d7360fb8aa5773936a05f72df651ba50b489fd5
[llvm-opt-report] Distinguish inlined contexts when optimizations differ

How code is optimized sometimes, perhaps often, depends on the context into
which it was inlined. This change allows llvm-opt-report to track the
differences between the optimizations performed, or not, in different contexts,
and when these differ, display those differences.

For example, this code:

  $ cat /tmp/q.cpp
  void bar();
  void foo(int n) {
    for (int i = 0; i < n; ++i)
      bar();
  }

  void quack() {
    foo(4);
  }

  void quack2() {
    foo(4);
  }

will now produce this report:

  < /home/hfinkel/src/llvm/test/tools/llvm-opt-report/Inputs/q.cpp
   2         | void bar();
   3         | void foo(int n) {
   [[
    > foo(int):
   4         |   for (int i = 0; i < n; ++i)
    > quack(), quack2():
   4  U4     |   for (int i = 0; i < n; ++i)
   ]]
   5         |     bar();
   6         | }
   7         |
   8         | void quack() {
   9 I       |   foo(4);
  10         | }
  11         |
  12         | void quack2() {
  13 I       |   foo(4);
  14         | }
  15         |

Note that the tool has demangled the function names, and grouped the reports
associated with line 4. This shows that the loop on line 4 was unrolled by a
factor of 4 when inlined into the functions quack() and quack2(), but not in
the function foo(int) itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283402 91177308-0d34-0410-b5e6-96231b3b80d8
test/tools/llvm-opt-report/Inputs/q.c [new file with mode: 0644]
test/tools/llvm-opt-report/Inputs/q.cpp [new file with mode: 0644]
test/tools/llvm-opt-report/Inputs/q.yaml [new file with mode: 0644]
test/tools/llvm-opt-report/Inputs/q2.c [new file with mode: 0644]
test/tools/llvm-opt-report/Inputs/q2.yaml [new file with mode: 0644]
test/tools/llvm-opt-report/Inputs/qx.yaml [new file with mode: 0644]
test/tools/llvm-opt-report/func-2.test [new file with mode: 0644]
test/tools/llvm-opt-report/func-x.test [new file with mode: 0644]
test/tools/llvm-opt-report/func.test [new file with mode: 0644]
tools/llvm-opt-report/CMakeLists.txt
tools/llvm-opt-report/OptReport.cpp