[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)
commit5aa02480594f861efc332650188eef6b2986a269
treecf02efcef81760eb154c5699708047245c466314
parentb3510afcd1eb1c03bb4b30b3a53cc5c6a9997227
[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.

llvm-svn: 283402
llvm/test/tools/llvm-opt-report/Inputs/q.c [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/Inputs/q.cpp [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/Inputs/q.yaml [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/Inputs/q2.c [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/Inputs/q2.yaml [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/Inputs/qx.yaml [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/func-2.test [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/func-x.test [new file with mode: 0644]
llvm/test/tools/llvm-opt-report/func.test [new file with mode: 0644]
llvm/tools/llvm-opt-report/CMakeLists.txt
llvm/tools/llvm-opt-report/OptReport.cpp