inline asm in inlined function / ECX clobbered / stack frame / naked

James Blachly james.blachly at gmail.com
Tue May 28 20:45:35 UTC 2019


On 5/8/19 11:42 AM, kinke wrote:
> I should probably add that the inline asm version can be simplified to a 
> much more readable:
> 
> return x <= 2 ? x : 2 << __asm!uint("bsrl $1, $0", "=r,r", x - 1);
> 
> Check out http://llvm.org/docs/LangRef.html#inline-asm-constraint-string 
> if interested in LLVM inline assembly.

Kinke,

Thank you for your extensive work and detailed answers. I will 
definitely take your advice and move to LLVM style inline asm.

Regarding my last unanswered(I think) question about why LDC/LLVM was 
not saving ECX when inlining the naked function:

since problem not evident when using the LLVM inline asm, this is 
appears to be a bug related to combination of function inlining and DMD 
style asm.



More information about the digitalmars-d-ldc mailing list