about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm
diff options
context:
space:
mode:
authoryvt <i@yvt.jp>2022-04-23 23:39:27 +0900
committeryvt <i@yvt.jp>2022-04-25 01:55:36 +0900
commit5d25b8fc45f66cdd1b19c87cce38eda86141dcf8 (patch)
tree0bccf321647bdd0a339c86a0824f2f66b701cbc4 /src/test/codegen/src-hash-algorithm
parent4210fd49cbea8ef241138a2fb77612f43e0b87a7 (diff)
downloadrust-5d25b8fc45f66cdd1b19c87cce38eda86141dcf8.tar.gz
rust-5d25b8fc45f66cdd1b19c87cce38eda86141dcf8.zip
Convert inline assembly `sym` operands into GCC input operands
This commit updates `<Builder as AsmBuilderMethods>::codegen_inline_asm`
to convert `sym` operands into `"X" (&func_or_static)` input operands
to indicate the dependency on the referenced symbols and prevent them
from being eliminated.

We follow the suit of the LLVM codegen with a mixture of its differing
techniques for `asm!` and `global_asm!`. The codegen module generates
input operands for the `sym` operands (as in `asm!` in cg_llvm).
However, the codegen module replaces all placeholders with mangled
symbol names before passing the assembly template string to the backend
(as in `global_asm!` in cg_llvm), which means these input operands are
never referenced in the final assembly template string.

Unlike the LLVM codegen, the input operand constraint must be `X`
instead of `s`. If the `s` constraint is used, GCC will employ checks to
make sure that the operand can really be represented by a simple
symbolic constant, thus rejecting symbols requiring GOT, etc. to
resolve. Such checks are unnecessary for Rust `sym` as it's up to
programmers to handle such complex cases, e.g., by manually appending
GOT addressing modifiers to the substituted symbol names.

Using the `X` constraint doesn't seem to generate any extra code, so
this will not compromise the property of naked functions.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions