www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - -O, -inline, AA's and compile times

// tested on DMD.119; WinXP

Write the following code to foo.d :

<code>
int[char[]] map;

void foo(char[] a, uint b)
{
	map[a] = b;
}

void bar()
{
}

void main()
{
	bar();
	bar();
	bar();
	bar();
	bar();
}
</code>

Now, in the body of bar(), paste this line 128 times:
foo("bar", 256);
(the string and nbr were chosen arbitrarily)

Compile foo.d as:
dmd foo.d -O -v -inline

Nothing really special happens. Now, in the main() function, replace 
each call to 'bar' by the contents of bar()'s body. Compile again. On my 
machine it took about 40 seconds for DMD to generate code for main()

/*
http://codeinsane.info/code/tmp/fast_foo.d
http://codeinsane.info/code/tmp/slow_foo.d
*/

The question is: why does it take so long to compile slow_foo.d with 
-inline and -O ?


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
Mar 27 2005