Thread overview
Inlining - am I mad?
Jul 03, 2004
Simon Hobbs
Jul 03, 2004
Charlie
Jul 03, 2004
Lisa Hobbs
Jul 03, 2004
Walter
July 03, 2004
Hey chaps,

Inlining doesn't seem to be working in v0.94. I've reduced the problem to this test program because it wasn't inlining a bunch of proper code:


import std.random;

int MulBy2(int a)
{
return a * 2;
}

int main ( char [] [] args )
{
int x = rand();
int y = MulBy2(x);
return y;
}


I'm using this command line:

c:\dmd\bin\dmd.exe test.d -O -release -inline -oftest.exe


And it doesn't inline the call to MulBy2.
Here's the debugger mixed source/disassembly window:


--- test.d --------------------------------------------------------------------

import std.random;

int MulBy2(int a)
00402010  add         eax,eax
{
return a * 2;
}
00402012  ret
00402013  int         3

int main ( char [] [] args )
00402014  push        eax
{
int x = rand();
int y = MulBy2(x);
00402015  call        _D3std6random4randFZk (402114h)
0040201A  call         (402010h)
return y;
}
0040201F  pop         ecx
--- No source file ------------------------------------------------------------
00402020  ret 00402021  int         3 00402022  int         3 00402023  int         3




Why isn't it inlining, please?

Si


July 03, 2004
Im not sure debug and inline work together, and how did u get embedded debug info without including the proper flags ?

You might want to try compiling to obj and using obj2asm.

C

In article <cc6nnr$tct$1@digitaldaemon.com>, Simon Hobbs says...
>
>Hey chaps,
>
>Inlining doesn't seem to be working in v0.94. I've reduced the problem to this test program because it wasn't inlining a bunch of proper code:
>
>
>import std.random;
>
>int MulBy2(int a)
>{
>return a * 2;
>}
>
>int main ( char [] [] args )
>{
>int x = rand();
>int y = MulBy2(x);
>return y;
>}
>
>
>I'm using this command line:
>
>c:\dmd\bin\dmd.exe test.d -O -release -inline -oftest.exe
>
>
>And it doesn't inline the call to MulBy2.
>Here's the debugger mixed source/disassembly window:
>
>
>--- test.d --------------------------------------------------------------------
>
>import std.random;
>
>int MulBy2(int a)
>00402010  add         eax,eax
>{
>return a * 2;
>}
>00402012  ret
>00402013  int         3
>
>int main ( char [] [] args )
>00402014  push        eax
>{
>int x = rand();
>int y = MulBy2(x);
>00402015  call        _D3std6random4randFZk (402114h)
>0040201A  call         (402010h)
>return y;
>}
>0040201F  pop         ecx
>--- No source file ------------------------------------------------------------
>00402020  ret 00402021  int         3 00402022  int         3 00402023  int         3
>
>
>
>
>Why isn't it inlining, please?
>
>Si
>
>


July 03, 2004
Right now, initializers aren't inline expanded. So if you wrote:
    int y;
    y = MulBy2(x);
it will inline expand.


"Simon Hobbs" <Simon_member@pathlink.com> wrote in message news:cc6nnr$tct$1@digitaldaemon.com...
> Hey chaps,
>
> Inlining doesn't seem to be working in v0.94. I've reduced the problem to
this
> test program because it wasn't inlining a bunch of proper code:
>
>
> import std.random;
>
> int MulBy2(int a)
> {
> return a * 2;
> }
>
> int main ( char [] [] args )
> {
> int x = rand();
> int y = MulBy2(x);
> return y;
> }
>
>
> I'm using this command line:
>
> c:\dmd\bin\dmd.exe test.d -O -release -inline -oftest.exe
>
>
> And it doesn't inline the call to MulBy2.
> Here's the debugger mixed source/disassembly window:
>
>
> --- 
test.d --------------------------------------------------------------------
>
> import std.random;
>
> int MulBy2(int a)
> 00402010  add         eax,eax
> {
> return a * 2;
> }
> 00402012  ret
> 00402013  int         3
>
> int main ( char [] [] args )
> 00402014  push        eax
> {
> int x = rand();
> int y = MulBy2(x);
> 00402015  call        _D3std6random4randFZk (402114h)
> 0040201A  call         (402010h)
> return y;
> }
> 0040201F  pop         ecx
> --- No source
file ------------------------------------------------------------
> 00402020  ret
> 00402021  int         3
> 00402022  int         3
> 00402023  int         3
>
>
>
>
> Why isn't it inlining, please?
>
> Si
>
>


July 03, 2004
Oops, I did actually have the -g flag on the command line as well. I just typed it out wrongly in my post


"Charlie" <Charlie_member@pathlink.com> wrote in message news:cc6pep$vv5$1@digitaldaemon.com...
> Im not sure debug and inline work together, and how did u get embedded
debug
> info without including the proper flags ?
>
> You might want to try compiling to obj and using obj2asm.
>
> C
>
> In article <cc6nnr$tct$1@digitaldaemon.com>, Simon Hobbs says...
> >
> >Hey chaps,
> >
> >Inlining doesn't seem to be working in v0.94. I've reduced the problem to
this
> >test program because it wasn't inlining a bunch of proper code:
> >
> >
> >import std.random;
> >
> >int MulBy2(int a)
> >{
> >return a * 2;
> >}
> >
> >int main ( char [] [] args )
> >{
> >int x = rand();
> >int y = MulBy2(x);
> >return y;
> >}
> >
> >
> >I'm using this command line:
> >
> >c:\dmd\bin\dmd.exe test.d -O -release -inline -oftest.exe
> >
> >
> >And it doesn't inline the call to MulBy2.
> >Here's the debugger mixed source/disassembly window:
> >
> >
> >--- 
test.d --------------------------------------------------------------------
> >
> >import std.random;
> >
> >int MulBy2(int a)
> >00402010  add         eax,eax
> >{
> >return a * 2;
> >}
> >00402012  ret
> >00402013  int         3
> >
> >int main ( char [] [] args )
> >00402014  push        eax
> >{
> >int x = rand();
> >int y = MulBy2(x);
> >00402015  call        _D3std6random4randFZk (402114h)
> >0040201A  call         (402010h)
> >return y;
> >}
> >0040201F  pop         ecx
> >--- No source
file ------------------------------------------------------------
> >00402020  ret
> >00402021  int         3
> >00402022  int         3
> >00402023  int         3
> >
> >
> >
> >
> >Why isn't it inlining, please?
> >
> >Si
> >
> >
>
>