Skip to content

Commit

Permalink
Auto merge of #103098 - Amanieu:asm-tied-fixed, r=bjorn3
Browse files Browse the repository at this point in the history
asm: Match clang behavior for inlateout fixed register operands

We have 2 options for representing LLVM constraints for `inlateout` operands on a fixed register (e.g. `r0`): `={r0},0` or `={r0},{r0}`.

This PR changes the behavior to the latter, which matches the behavior of Clang since https://reviews.llvm.org/D87279.
  • Loading branch information
bors committed Nov 4, 2022
2 parents 2efb0cd + 6bfe7f0 commit 47c008e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,24 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
op_idx.insert(idx, constraints.len());
constraints.push(reg_to_llvm(reg, Some(&value.layout)));
}
InlineAsmOperandRef::InOut { reg, late: _, in_value, out_place: _ } => {
InlineAsmOperandRef::InOut { reg, late, in_value, out_place: _ } => {
let value = llvm_fixup_input(
self,
in_value.immediate(),
reg.reg_class(),
&in_value.layout,
);
inputs.push(value);
constraints.push(format!("{}", op_idx[&idx]));

// In the case of fixed registers, we have the choice of
// either using a tied operand or duplicating the constraint.
// We prefer the latter because it matches the behavior of
// Clang.
if late && matches!(reg, InlineAsmRegOrRegClass::Reg(_)) {
constraints.push(format!("{}", reg_to_llvm(reg, Some(&in_value.layout))));
} else {
constraints.push(format!("{}", op_idx[&idx]));
}
}
InlineAsmOperandRef::SymFn { instance } => {
inputs.push(self.cx.get_fn(instance));
Expand Down

0 comments on commit 47c008e

Please sign in to comment.