Hi, I recently read a thread in rustlang forum about "Should we ever stabilize inline assembly?" and some of the related threads. One motivation for stabilizing it that didn't appear in the discussion is that it can greatly help in successfully implementing constant-time code, which can be really important for cryptography: for example, see these links: https://software.intel.com/security-software-guidance/insights/guidelines-mitigating-timing-side-channels-against-cryptographic-implementations , https://www.chosenplaintext.ca/open-source/rust-timing-shield/security , https://github.com/dalek-cryptography/subtle/blob/master/src/lib.rs#L144 . One question I would have for cranelift folks is, if I don't have inline asm, is there any way that I can be sure I will get "CMOV" as opposed to a branch at some critical place in my program? Or would they want me to simply use out-of-line assembly .S files? Thanks for all your hard work on this feature and I hope your proposal is successful
I don't think cranelift will ever support inline assembly, but in the future rustc may be able to automatically translate inline assembly into calls to external assembler files. This was taken into account for the design of the
Currently the only places where Cranelift turns a non-branching instruction into a branching one are some float instructions and
select I think. Cranelift has support for
cmov, but it only emits it for
ifselect with 32bit or 64bit ints. At the moment it is missing an optimization to go from
ifselect, which means that
cmov isn't actually used by cg_clif (a Cranelift backend for rustc of mine).