cancel
Showing results for 
Search instead for 
Did you mean: 

Does is SDCC the DCE optimisation?

Vyacheslav Azarov
Associate III
Posted on July 14, 2018 at 07:05

Hello anyone,

When compiling a program including Standard Peripheral Library in the output *.elf file, all unused modules was included. Does is SDCC the dead code elimination optimization and how to activate it?

Thanks in advance.

#dce #optimalization #sdcc #stm8-toolchain
7 REPLIES 7
henry.dick
Senior II
Posted on July 14, 2018 at 16:50

'

Does is SDCC the dead code elimination optimization and how to activate it?'

it does, in such a way that it doesn't.

you will need to put each function in a separate file for the unused functions to not be linked in. for modern modular programming, that's not a workable approach.

Posted on July 14, 2018 at 20:07

It's a pity. All modern compilers exclude unused functions from the code. Those, assembly occurs at the level of object files, not by functions. As in the first compilers. And there is no undocumented magic key?   Thanks.

Posted on July 15, 2018 at 22:42

'

It's a pity.

 '

indeed. it essentially made the compiler unusable - i ruled it out very early based on that.

Posted on July 16, 2018 at 02:34

I think it is more the job of the linker rather than the compiler. I've written linkers and librarians in the past when the vendor supplied tools are unsatisfactory, or where I want to feed objects to different tools from different vendors, or on different platforms.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 16, 2018 at 05:54

Thanks for reply Clive, Modern compilers does complex link time inter-procedural optimizations. And it becomes difficult to separate these two functions, the actual compilation and the linking. As an example is can view GCC for AVR .

Posted on July 16, 2018 at 09:45

SDCC, however, still has separate compiler and linker.

Philipp

Posted on July 16, 2018 at 09:50

Compilers could eliminate unused static functions, but for other functions it would be done in the linker.

Philipp