LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 16474 - extremely slow compilation at -O3 than -O2 (~400 seconds vs. ~0.1 seconds)
Summary: extremely slow compilation at -O3 than -O2 (~400 seconds vs. ~0.1 seconds)
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: LLVM Codegen (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 17461 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-06-27 13:38 PDT by Zhendong Su
Modified: 2013-11-03 12:38 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2013-06-27 13:38:06 PDT
The following code takes much longer to compile at -O3 than at -O2, using the current clang-trunk and clang 3.3 on x86_64-linux. For additional reference, gcc 4.8.1 at -O3 takes ~0.14 seconds, and icc 13.1.1 at -O3 takes ~3.4 seconds.  

It appears to be a regression from clang 3.2 (which takes about 9 seconds at -O3).

% clang-trunk -v
clang version 3.4 (trunk 185061)
Target: x86_64-pc-linux-gnu
Thread model: posix
% time clang-trunk -O3 reduced.c

real	6m35.619s
user	4m56.983s
sys	0m0.080s
%
% time clang-trunk -O2 reduced.c

real	0m0.102s
user	0m0.028s
sys	0m0.008s
%
% time clang-3.2 -O3 reduced.c

real	0m9.003s
user	0m7.764s
sys	0m0.024s
%
% time gcc-4.8 -O3 reduced.c

real	0m0.138s
user	0m0.036s
sys	0m0.020s
%
% time icc -O3 reduced.c

real	0m3.374s
user	0m0.232s
sys	0m2.028s


-----------------------------------------------------

int a = 1, b, c, *d = &c, e, f, g, k, l, x; 

static int * volatile *h = &d;
static int * volatile **j = &h;

void foo (int p) 
{
  d = &p;
}

void bar ()
{
  int i; 

  foo (0);
  for (i = 0; i < 27; ++i) 
    for (f = 0; f < 3; f++)  
      for (g = 0; g < 3; g++) 
	{
	  for (b = 0; b < 3; b++)
	    if (e)
	      break;
	  foo (0); 
	}
}

static void baz ()
{
  for (; a >= 0; a--) 
    for (k = 3; k > 0; k--)
      for (l = 0; l < 6; l++) 
	{
	  bar (); 
	  **j = &x; 
	}
}

int main ()
{
  baz ();
  return 0;
}
Comment 1 Benjamin Kramer 2013-06-29 10:06:12 PDT
Two issues here:

1. We create thousands of dead lifetime.start/lifetime.end pairs. Maybe some pass should clean them up.
2. PointerMayBeCaptured has a loophole in enforcing the threshold on number of uses when it encounters a switch instruction.
Comment 2 Benjamin Kramer 2013-10-03 07:44:09 PDT
*** Bug 17461 has been marked as a duplicate of this bug. ***
Comment 3 Benjamin Kramer 2013-10-03 08:24:35 PDT
Fixed issue #2 in r191896, compile time should be down to "normal" levels now.
Comment 4 Bill Wendling 2013-11-03 11:09:39 PST
Please file a new bug about the dead lifetime markers.
Comment 5 Benjamin Kramer 2013-11-03 12:38:38 PST
(In reply to comment #4)
> Please file a new bug about the dead lifetime markers.

Bug 17790