[llvm] r342578 - [X86] Handle COPYs of physregs better (regalloc hints)

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 12:52:14 PDT 2018


Sure,
I wasn't able to reduce the test case much -- the long compilation
time seems to be a factor of the length of the method, so a small
method wouldn't reproduce it.
$ time bin/llc /tmp/repro.ll -o /tmp/repro-r342577.o
bin/llc /tmp/repro.ll -o /tmp/repro-r342577.o  2.87s user 0.07s system
99% cpu 2.942 total
$ time bin/llc /tmp/repro.ll -o /tmp/repro-r342578.o
bin/llc /tmp/repro.ll -o /tmp/repro-r342578.o  7.71s user 0.08s system
99% cpu 7.795 total
I've attached repro.ll, but I generated it from the C++ snippet above,
with a copy of Eigen pulled from a few minutes ago. It wasn't slow
enough with the version of eigen at head, so I added a 35x35 dummy
matrix to the example.

I've noticed a small sampling of other strange failures caused by this
commit as well, one of which just revealed an actual bug in a test,
but another which I haven't quite figured out yet -- I'm still trying
to see if it's a bug with this commit.

On Thu, Sep 27, 2018 at 3:45 AM Jonas Paulsson
<paulsson at linux.vnet.ibm.com> wrote:
>
> Hi,
>
> I would be happy to take a look. Could you please post a preprocessed /
> bitcode (reduced if possible) test case, preferably llc input, with a
> command line?
>
> /Jonas
>
>
> On 2018-09-27 10:14, Simon Pilgrim wrote:
> > This is a question for Jonas - I just kept the x86 tests up to date
> > until the patch was accepted.
> >
> > On 27/09/2018 00:08, Jordan Rupprecht wrote:
> >> Hi Simon,
> >>
> >> We seem to have some extreme compile slowdowns in sanitizer (asan,
> >> msan, and tsan) modes after r342578. In one case, we've seen something
> >> built with tsan and -O2 go from 20 seconds to 12 minutes. It doesn't
> >> seem to be a general slowdown, just certain "interesting" pieces of
> >> code (heavy template users, generated code that has thousands of
> >> expressions, etc.)
> >>
> >> We've seen it in all sanitizer modes, but the tsan example mentioned
> >> can be distilled down to something like this:
> >>
> >> $ time bin/clang -c repro.cpp -I</path/to/eigen> -O2
> >> -fno-strict-aliasing -fsanitize=thread -o repro.o
> >> @r342577: 5.25s user 0.68s system 99% cpu 5.984 total
> >> @r342578: 9.50s user 0.26s system 99% cpu 9.811 total
> >>
> >> $ cat repro.cpp
> >> #include <Eigen/Core>
> >> Eigen::MatrixXi foo(int x) {
> >>    Eigen::MatrixXi m;
> >>    switch (x) {
> >>      case 3:
> >>        m.resize(3, 3);
> >>        m << 1, 2, 3,  //
> >>            1, 2, 3,   //
> >>            1, 2, 3;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        break;
> >>      case 5:
> >>        m.resize(5, 5);
> >>        m << 1, 2, 3, 4, 5,  //
> >>            1, 2, 3, 4, 5,   //
> >>            1, 2, 3, 4, 5,   //
> >>            1, 2, 3, 4, 5,   //
> >>            1, 2, 3, 4, 5;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        break;
> >>      case 7:
> >>        m.resize(7, 7);
> >>        m << 1, 2, 3, 4, 5, 6, 7,  //
> >>            1, 2, 3, 4, 5, 6, 7,   //
> >>            1, 2, 3, 4, 5, 6, 7,   //
> >>            1, 2, 3, 4, 5, 6, 7,   //
> >>            1, 2, 3, 4, 5, 6, 7,   //
> >>            1, 2, 3, 4, 5, 6, 7,   //
> >>            1, 2, 3, 4, 5, 6, 7;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        break;
> >>      case 25:
> >>        m.resize(25, 25);
> >>        m << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
> >> 17, 18, 19,
> >>            20, 21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        break;
> >>      case 30:
> >>        m.resize(30, 30);
> >>        m << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
> >> 17, 18, 19,
> >>            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30,  //
> >>            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> >> 18, 19, 20,
> >>            21, 22, 23, 24, 25, 26, 27, 28, 29, 30;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        m.array() -= 1;
> >>        break;
> >>      default:
> >>        break;
> >>    }
> >>    return m;
> >> }
> >>
> >> In some cases, we can workaround this by rewriting the methods to be
> >> simpler. However, it'd be nice to understand what's going on -- is
> >> there a O(n^2) algorithm that enableMultipleCopyHints() is enabling
> >> that would cause large methods to be slow to compile?
> >>
> >> Thanks -- Jordan
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repro.ll
Type: application/octet-stream
Size: 5081544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/45c999ad/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4849 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/45c999ad/attachment-0001.bin>


More information about the llvm-commits mailing list