Detailed inline behavior of dmd?
qznc
qznc at web.de
Tue Aug 6 04:49:55 PDT 2013
On Tuesday, 6 August 2013 at 11:01:35 UTC, SteveGuo wrote:
> D supports inline functions, But I want to know the details.
>
> 2. The depth of inline.
> 3. If I add the switch -inline when compiling, it will inline
> everything no matter how complex the function is?
As far as I know, no compiler specifies anything for this.
Inlining is a difficult optimization, because it is hard to
quantify if a specific call is worth inlining. Usually, there are
handwavy heuristics and various magic numbers. Nobody should
depend on exact behavior here. For specific cases, you can always
inspect the assembly.
Inlining everything is not possible in general. Consider
recursive functions aka circles in the call graph. Dynamic
binding and function pointers lead to calls of unknown functions.
More information about the Digitalmars-d
mailing list