Skip to content

Commit ca1f3e7

Browse files
committed
Sync from rust bafe8d0
2 parents dc973ae + a063e13 commit ca1f3e7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/inline_asm.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
106106
let mut asm_gen = InlineAssemblyGenerator {
107107
tcx: fx.tcx,
108108
arch: fx.tcx.sess.asm_arch.unwrap(),
109+
enclosing_def_id: fx.instance.def_id(),
109110
template,
110111
operands,
111112
options,
@@ -169,6 +170,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
169170
struct InlineAssemblyGenerator<'a, 'tcx> {
170171
tcx: TyCtxt<'tcx>,
171172
arch: InlineAsmArch,
173+
enclosing_def_id: DefId,
172174
template: &'a [InlineAsmTemplatePiece],
173175
operands: &'a [InlineAsmOperand<'tcx>],
174176
options: InlineAsmOptions,
@@ -182,7 +184,12 @@ struct InlineAssemblyGenerator<'a, 'tcx> {
182184
impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
183185
fn allocate_registers(&mut self) {
184186
let sess = self.tcx.sess;
185-
let map = allocatable_registers(self.arch, &sess.target_features, &sess.target);
187+
let map = allocatable_registers(
188+
self.arch,
189+
sess.relocation_model(),
190+
self.tcx.asm_target_features(self.enclosing_def_id),
191+
&sess.target,
192+
);
186193
let mut allocated = FxHashMap::<_, (bool, bool)>::default();
187194
let mut regs = vec![None; self.operands.len()];
188195

@@ -313,14 +320,9 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
313320
let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
314321

315322
// Allocate stack slots for saving clobbered registers
316-
let abi_clobber = InlineAsmClobberAbi::parse(
317-
self.arch,
318-
&self.tcx.sess.target_features,
319-
&self.tcx.sess.target,
320-
sym::C,
321-
)
322-
.unwrap()
323-
.clobbered_regs();
323+
let abi_clobber = InlineAsmClobberAbi::parse(self.arch, &self.tcx.sess.target, sym::C)
324+
.unwrap()
325+
.clobbered_regs();
324326
for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
325327
let mut need_save = true;
326328
// If the register overlaps with a register clobbered by function call, then

0 commit comments

Comments
 (0)