Dead Code Elimination
user1234
user1234 at 12.de
Wed Oct 21 09:32:25 UTC 2026
On Sunday, 18 October 2026 at 15:33:17 UTC, libxmoc wrote:
> I noticed that dmd doesn't do DCE, my executable is quite large
> for what it does. Any plan to add that? I tried to do it
> myself, a simple bool in DSymbol + a visitor (yoinked it from
> the unused import PR) to scan things, and it shrank build time
> by ~15% and executable went down to 3.5mb from 5.5mb.
>
> Surely someone smarter than me could do even better.
It's hard to say when something is used, simple example:
```d
void unused(){}
void main()
{
import core.stdc.stdio;
printf("%p\n",&unused);
}
```
same problem with virtual functions.
Otherwise what you call DCE is rather WPO (whole program
optimization).
More information about the Digitalmars-d
mailing list