[llvm-bugs] [Bug 47382] New: compile time over an hour under LTO+O3

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 1 05:35:59 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47382

            Bug ID: 47382
           Summary: compile time over an hour under LTO+O3
           Product: new-bugs
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: zhangtiehu at huawei.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

//test.c
int a, b, c, d;
void e()
{
  short f = &c;
  int g = d = 0;
  for (; d <= 3; d++) {
    a = 0;
    for (; a <= 4; a++)
      g ^= g ?: f;
    b = g;
  }
}
void main() {}

clang -O3 -Wl,-z,notext -flto=full test.c -w

In this case, the compile time is over an hour. I use "-opt-bisect-limit" to
locate the fault. There are two passes may cause the problem:
1. "Combine redundant instructions on function"
There is an operation of "ConstantFoldInstruction(Inst, DL, TLI)", it will
substitue the value from the former expressions into any instructions later
that use the final values. In this case, there are many group of instructions
like this, and the later group is depend on the result of former.
=======================================
  %xor.3 = xor i32 %cond.3, %xor.2
  %tobool.4 = icmp ne i32 %xor.3, 0
  %cond.4 = select i1 %tobool.4, i32 %xor.3, i32 sext (i16 ptrtoint (i32* @c to
i16) to i32)
  %xor.4 = xor i32 %cond.4, %xor.3
============================================
We can describe the lenth of expression as preA, A, B, C, after an iteration,
the lenth of C will be three times of preA:
==============
A = preA
B = A + preA = 2 * preA
C = B + preA = 3 * preA
==============
After N group of "ConstantFoldInstruction", the lenth of final expression will
be preA * 3^N. In this case the IR lenth is about preA * 3^20. It is too large
to process which causes the issue.

2. "Induction Variable Simplification on loop"
This pass has similar problem with InstCombine when executing
"rewriteLoopExitValues".

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200901/498c5abe/attachment.html>


More information about the llvm-bugs mailing list