Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 16, 2019 auto remove unused function arguments from call chain | ||||
---|---|---|---|---|
| ||||
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 ? |
November 16, 2019 Re: auto remove unused function arguments from call chain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Newbie2019 | 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
|
November 17, 2019 Re: auto remove unused function arguments from call chain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | 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.
>
> -Johan
most of them are internal to a module for debug.
Is LDC already do it, or could be done in future?
|
November 17, 2019 Re: auto remove unused function arguments from call chain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Newbie2019 | 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: >> 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 > > > most of them are internal to a module for debug. > > Is LDC already do it, or could be done in future? Already, just check in https://d.godbolt.org This was asked a few months before: https://forum.dlang.org/post/zuunbgthdschuncmaduo@forum.dlang.org |
November 19, 2019 Re: auto remove unused function arguments from call chain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Boris Carvajal | 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.org
Thanks for the tips, I forget I has asked before.
So it only work if the target function is inlined ?
|
Copyright © 1999-2021 by the D Language Foundation