4 ms·
"Dead code elimination" usually refers to smaller-scale compiler optimizations where within a function, you're discarding pieces of code that will never be reac
by munificent 3y ago
"Dead code elimination" usually refers to smaller-scale compiler optimizations where within a function, you're discarding pieces of code that will never be reached.
"Tree-shaking" refers to a whole-program analysis where you discard entire modules and functions if they are never invoked.
They are conceptually the same, but a compiler author will likely have to implement them separately, so having two names helps.
- wruza 3y agoFeels like it became “usually” only recently, cause before “web2.0” DCE always meant eliminating both codepaths and unreachable symbols.
- flohofwoe 3y agoFWIW I never encountered 'tree shaking' in the C/C++ world (only in the Javascript world). Commonly in the C/C++ world, dead-code-elimination is used for anything that removes (or ignores in the first place) unused code and data. And I think with LTO it's all the same anyway (in the past there were a lot of gnarly details how the compiler/librarian actually created a static link library to avoid linking code that's not actually used, but that all doesn't matter anymore with LTO).