Menu

auto-inlining of functions by the optimizer

Help
2011-03-28
2013-03-12
  • Bob Frankel

    Bob Frankel - 2011-03-28

    i'm just getting started with SDCC, and was wondering if the optimizer will *auto-inline* small functions that all live in a single .c source file….  having used other GCC 4.x compilers that apparently support this feature, i eschewed use of macros in favor of a more readable style of programming….  i do, however, rely on the compiler automatically inlining these functions….

    does this feature exist, and how does one enable it???

    thanks in advance

     
  • David Cary

    David Cary - 2011-03-29

    So you're looking for something similar to gcc's "-fno-inline-small-functions" option, "-finline-small-functions" option, "-finline-functions" option, "-finline-functions-called-once" option, "__noinline__" attribute, etc.?

    Have you ever *measured* the difference between inlined functions and normal function?
    The systems where I would use SDCC is more limited by memory space than by speed, and cases where inlining the function actually saves memory space seem pretty rare in my programs.

    I haven't yet found a SDCC command-line option that does "smart" inlining like GCC.
    As a work-around, could manually edit your source code to put the "static inline" attribute at each of those small functions that you want to inline?
    It appears that "static inline" works the same in both GCC and SDCC now. http://www.greenend.org.uk/rjk/2003/03/inline.html

    Inline functions were added to SDCC in 2007. https://sourceforge.net/apps/trac/sdcc/wiki/SDCC%202.7.0%20Release

    I see one person claim that "You'll need to add -std-c99 to the command line to make SDCC accept the
    inline keyword." http://www.mail-archive.com/sdcc-user@lists.sourceforge.net/msg01473.html

     

Log in to post a comment.

MongoDB Logo MongoDB