Dead Code Elimination
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Oct 18 18:16:13 UTC 2026
On 19/10/2026 4:33 AM, 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.
Doesn't surprise me.
DCE can only work on shared libraries, executables, and local to object
file symbols (mostly private but also not limited to that i.e.
ModuleInfo must emit).
The way dmd has traditionally handled it is to emit static libraries and
let the linker deal with it.
More information about the Digitalmars-d
mailing list