[Issue 15159] New: Static nested function prevent inlining
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Oct  5 03:37:19 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15159
          Issue ID: 15159
           Summary: Static nested function prevent inlining
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dmitry.olsh at gmail.com
Turns out that even _static_ nested function prevents inlining. Testing on
DMD-v2.069 HEAD.
Test case:
int boo()
{
    pragma(inline, true);
    static int foo(int k){ return k; }
    return foo(1);
}
// needed else it will ignore inliner pass
unittest
{
   assert(boo() == 1);
}
fails:
.\boo.d(1): Error: function boo.boo cannot inline function
While this works:
static int foo(int k){ return k; }
int boo()
{
    pragma(inline, true);
    return foo(1);
}
// needed else it will ignore inliner pass
unittest
{
   assert(boo() == 1);
}
--
    
    
More information about the Digitalmars-d-bugs
mailing list