digitalmars.D.learn - Is DMD still not inlining "inline asm"?
- rempas (2/2) Nov 11 2021 I've seen from
- Adam D Ruppe (3/5) Nov 11 2021 You really shouldn't expect dmd to inline *anything*.
- rempas (2/5) Nov 11 2021 Oh yeah! I just thought to ask anyway! Thanks a lot for your time!
- Basile B. (10/12) Nov 11 2021 Yes, this is still the case. A particularity of DMD inliner is
- rempas (3/13) Nov 11 2021 What? Not even GCC or Clang? Someone said that LDC2 does it with
- max haughton (2/18) Nov 11 2021 There's an attribute to tell it the function is safe to inline.
- rempas (2/3) Nov 12 2021 And can't you do that with inline asm?
- max haughton (3/8) Nov 12 2021 Not always. The attribute is intended for naked asm since
- rempas (2/4) Nov 12 2021 Got that! Thanks for the info!
- Elronnd (3/4) Nov 11 2021 GCC can do it. Somewhat notoriously, LTO can lead to bugs from
- rempas (3/5) Nov 12 2021 That's really interesting to hear! Do we have any cases where
- Basile B. (3/8) Nov 13 2021 I have missed the LTO train TBH, gotta try that once...
- Guillaume Piolat (3/7) Nov 14 2021 LDC can also do it with GCC asm constraints, however it is
I've seen from [this](https://forum.dlang.org/post/op.vrzngqeavxi10f biotronic-laptop) reply in a thread from 2011 that DMD will not inline functions that contain inline assembly. Is this still the case?
Nov 11 2021
On Thursday, 11 November 2021 at 08:58:43 UTC, rempas wrote:I've seen from [this](https://forum.dlang.org/post/op.vrzngqeavxi10f biotronic-laptop) reply in a thread from 2011 that DMD will not inline functions that contain inline assembly. Is this still the case?You really shouldn't expect dmd to inline *anything*. Or to optimize anything for that matter. That isn't its strength.
Nov 11 2021
On Thursday, 11 November 2021 at 12:05:14 UTC, Adam D Ruppe wrote:You really shouldn't expect dmd to inline *anything*. Or to optimize anything for that matter. That isn't its strength.Oh yeah! I just thought to ask anyway! Thanks a lot for your time!
Nov 11 2021
On Thursday, 11 November 2021 at 08:58:43 UTC, rempas wrote:I've seen from [this](https://forum.dlang.org/post/op.vrzngqeavxi10f biotronic-laptop) reply in a thread from 2011 that DMD will not inline functions that contain inline assembly. Is this still the case?Yes, this is still the case. A particularity of DMD inliner is that it does its job in the front-end, so inlining asm is totally impossible. Then, even if inlining was done in the backend inlining of asm would not be guaranteed because the byte code is generated at a very late stag, which causes problem with the registry allocator, the preservation of the stack, etc. For example ldc2 does not inline a trival asm func https://godbolt.org/z/1W6r693Tq. As for now, I know no compiler that can do that.
Nov 11 2021
On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote:Yes, this is still the case. A particularity of DMD inliner is that it does its job in the front-end, so inlining asm is totally impossible. Then, even if inlining was done in the backend inlining of asm would not be guaranteed because the byte code is generated at a very late stag, which causes problem with the registry allocator, the preservation of the stack, etc. For example ldc2 does not inline a trival asm func https://godbolt.org/z/1W6r693Tq. As for now, I know no compiler that can do that.What? Not even GCC or Clang? Someone said that LDC2 does it with two ways in the thread I linked
Nov 11 2021
On Thursday, 11 November 2021 at 17:29:33 UTC, rempas wrote:On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote:There's an attribute to tell it the function is safe to inline.Yes, this is still the case. A particularity of DMD inliner is that it does its job in the front-end, so inlining asm is totally impossible. Then, even if inlining was done in the backend inlining of asm would not be guaranteed because the byte code is generated at a very late stag, which causes problem with the registry allocator, the preservation of the stack, etc. For example ldc2 does not inline a trival asm func https://godbolt.org/z/1W6r693Tq. As for now, I know no compiler that can do that.What? Not even GCC or Clang? Someone said that LDC2 does it with two ways in the thread I linked
Nov 11 2021
On Thursday, 11 November 2021 at 19:22:33 UTC, max haughton wrote:There's an attribute to tell it the function is safe to inline.And can't you do that with inline asm?
Nov 12 2021
On Friday, 12 November 2021 at 11:32:16 UTC, rempas wrote:On Thursday, 11 November 2021 at 19:22:33 UTC, max haughton wrote:Not always. The attribute is intended for naked asm since inlining could be completely wrong in this case.There's an attribute to tell it the function is safe to inline.And can't you do that with inline asm?
Nov 12 2021
On Friday, 12 November 2021 at 15:10:19 UTC, max haughton wrote:Not always. The attribute is intended for naked asm since inlining could be completely wrong in this case.Got that! Thanks for the info!
Nov 12 2021
On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote:As for now, I know no compiler that can do that.GCC can do it. Somewhat notoriously, LTO can lead to bugs from underspecified asm constraints following cross-TU inlining.
Nov 11 2021
On Friday, 12 November 2021 at 00:46:05 UTC, Elronnd wrote:GCC can do it. Somewhat notoriously, LTO can lead to bugs from underspecified asm constraints following cross-TU inlining.That's really interesting to hear! Do we have any cases where this happened to software that was used for production?
Nov 12 2021
On Friday, 12 November 2021 at 00:46:05 UTC, Elronnd wrote:On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote:you meant "infamously" ?As for now, I know no compiler that can do that.GCC can do it. Somewhat notoriously,LTO can lead to bugs from underspecified asm constraints following cross-TU inlining.I have missed the LTO train TBH, gotta try that once...
Nov 13 2021
On Friday, 12 November 2021 at 00:46:05 UTC, Elronnd wrote:On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote:LDC can also do it with GCC asm constraints, however it is atrociously hard to get documentation and examples for this.As for now, I know no compiler that can do that.GCC can do it. Somewhat notoriously, LTO can lead to bugs from underspecified asm constraints following cross-TU inlining.
Nov 14 2021