digitalmars.D.ldc - auto remove unused function arguments from call chain
- Newbie2019 (16/16) Nov 15 2019 Is it possible to add optimization to remove unused function
- Johan Engelen (8/11) Nov 16 2019 In general, no. Because the function signature must be obeyed
- Newbie2019 (4/11) Nov 16 2019 most of them are internal to a module for debug.
- Boris Carvajal (4/16) Nov 17 2019 Already, just check in https://d.godbolt.org
- Newbie2019 (3/6) Nov 19 2019 Thanks for the tips, I forget I has asked before.
Is it possible to add optimization to remove unused function arguments in binary generate ? for example: ```d void doWork(int args, string file, size_t line) { version(DEV_DEBUG) { Log.i("info from file %s line %d", file, line); } do_the_real_work(); } void myApp(string file = __FILE__, size_t line = __LINE__){ doWork(args, file, line); } ``` when build without version DEV_DEBUG, the file and line is never used. will ldc able to auto remove it from the binary code ?
Nov 15 2019
On Saturday, 16 November 2019 at 04:22:17 UTC, Newbie2019 wrote:when build without version DEV_DEBUG, the file and line is never used. will ldc able to auto remove it from the binary code ?In general, no. Because the function signature must be obeyed such that the function can be called from anywhere without knowing the optimizations inside of it. If the function is internal to a module and the function is not exported, then yes the optimization is perhaps legal. So LTO might be allowed (and able) to do it, but I don't know. -Johan
Nov 16 2019
On Saturday, 16 November 2019 at 11:25:35 UTC, Johan Engelen wrote:In general, no. Because the function signature must be obeyed such that the function can be called from anywhere without knowing the optimizations inside of it. If the function is internal to a module and the function is not exported, then yes the optimization is perhaps legal. So LTO might be allowed (and able) to do it, but I don't know. -Johanmost of them are internal to a module for debug. Is LDC already do it, or could be done in future?
Nov 16 2019
On Sunday, 17 November 2019 at 06:42:48 UTC, Newbie2019 wrote:On Saturday, 16 November 2019 at 11:25:35 UTC, Johan Engelen wrote:Already, just check in https://d.godbolt.org This was asked a few months before: https://forum.dlang.org/post/zuunbgthdschuncmaduo forum.dlang.orgIn general, no. Because the function signature must be obeyed such that the function can be called from anywhere without knowing the optimizations inside of it. If the function is internal to a module and the function is not exported, then yes the optimization is perhaps legal. So LTO might be allowed (and able) to do it, but I don't know. -Johanmost of them are internal to a module for debug. Is LDC already do it, or could be done in future?
Nov 17 2019
On Sunday, 17 November 2019 at 11:40:27 UTC, Boris Carvajal wrote:Already, just check in https://d.godbolt.org This was asked a few months before: https://forum.dlang.org/post/zuunbgthdschuncmaduo forum.dlang.orgThanks for the tips, I forget I has asked before. So it only work if the target function is inlined ?
Nov 19 2019