Early Tail Duplication Inefficiency

I have a file for which clang-7 takes over 2 hours to compile with -O3. For the same file, clang-5 takes less than 2 minutes (which is also high IMHO). I will try to create a test case (but it is pretty simple, it only contains initializations of many arrays of structs where the structs are of the following form:

struct Foo {

EnumType1 e1; // there are 700+ enum labels

std::string s1;

EnumType2 e2; // 5 possible values for e2

std::string s2;

std::string s3;

};

// A large array with 10K+ elements

Foo array1[] = {

{ EnumType1Label1, “some string”, EnumType2Label1, “another string”, “yet another string” },

:

:

};

// 11 more arrays like above but most of them have only a few hundred elements

:

:

I would like to know if a similar problem had been reported before. A quick search didn’t find anything…

Clang-5 -ftime-report shows:

I didn’t see any response on this. Is there any way to turn off early tail duplication with a clang-7 option (other than completely turning off all optimizations)? The issue is reproducible with a very simple test case. Clang-7 with optimizations turned on takes hours compared to minutes with clang-5.0. Here is a simple cooked up test (the real-life example is of course different but this simple test exposes the same inefficiency):

// test.cpp

#include

struct Foo {

std::string s1;

std::string s2;

std::string s3;

};

Foo Array[] = {

{ “0”, “0”, “0” },

{ “1”, “1”, “1” },

:

:

:

{ “9999”, “9999”, “9999” }

};

Compile:

% clang++ -c -O3 test.cpp

Takes hours!

Try passing “-mllvm disable-early-taildup=true” to clang

I think a bug report would be useful to track the issue. It would be great if you could file one here: https://bugs.llvm.org/
Ideally with a reproducer.

Thanks,
Florian