[ScopInfo] Do not use LLVM names to identify statements, arrays, and parameters
authorTobias Grosser <tobias@grosser.es>
Wed, 3 May 2017 20:08:52 +0000 (20:08 +0000)
committerTobias Grosser <tobias@grosser.es>
Wed, 3 May 2017 20:08:52 +0000 (20:08 +0000)
commite2ccc3fb338800134dc744091bcceaf4d3c778ce
tree6b05c93694e0bbaab9ff1993fe62de34051169d4
parent4f145b2a5992c7c7488c90312f8efe7b73a749bb
[ScopInfo] Do not use LLVM names to identify statements, arrays, and parameters

LLVM-IR names are commonly available in debug builds, but often not in release
builds. Hence, using LLVM-IR names to identify statements or memory reference
results makes the behavior of Polly depend on the compile mode. This is
undesirable. Hence, we now just number the statements instead of using LLVM-IR
names to identify them (this issue has previously been brought up by Zino
Benaissa).

However, as LLVM-IR names help in making test cases more readable, we add an
option '-polly-use-llvm-names' to still use LLVM-IR names. This flag is by
default set in the polly tests to make test cases more readable.

This change reduces the time in ScopInfo from 32 seconds to 2 seconds for the
following test case provided by Eli Friedman <efriedma@codeaurora.org> (already
used in one of the previous commits):

  struct X { int x; };
  void a();
  #define SIG (int x, X **y, X **z)
  typedef void (*fn)SIG;
  #define FN { for (int i = 0; i < x; ++i) { (*y)[i].x += (*z)[i].x; } a(); }
  #define FN5 FN FN FN FN FN
  #define FN25 FN5 FN5 FN5 FN5
  #define FN125 FN25 FN25 FN25 FN25 FN25
  #define FN250 FN125 FN125
  #define FN1250 FN250 FN250 FN250 FN250 FN250
  void x SIG { FN1250 }

For a larger benchmark I have on-hand (10000 loops), this reduces the time for
running -polly-scops from 5 minutes to 4 minutes, a reduction by 20%.

The reason for this large speedup is that our previous use of printAsOperand
had a quadratic cost, as for each printed and unnamed operand the full function
was scanned to find the instruction number that identifies the operand.

We do not need to adjust the way memory reference ids are constructured, as
they do not use LLVM values.

Reviewed by: efriedma

Tags: #polly

Differential Revision: https://reviews.llvm.org/D32789

llvm-svn: 302072
polly/include/polly/ScopInfo.h
polly/include/polly/Support/GICHelper.h
polly/lib/Analysis/ScopInfo.cpp
polly/lib/Support/GICHelper.cpp
polly/test/ScopInfo/unnamed_nonaffine.ll [new file with mode: 0644]
polly/test/ScopInfo/unnamed_stmts.ll [new file with mode: 0644]
polly/test/lit.site.cfg.in