Avoid per-register closure expansions
This commit is contained in:
parent
3f1e30a0a5
commit
5980a17c52
1 changed files with 64 additions and 59 deletions
|
@ -342,9 +342,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
|
||||
// Flag to output the error only once per operand
|
||||
let mut skip = false;
|
||||
reg.overlapping_regs(|r| {
|
||||
|
||||
let mut check = |used_regs: &mut FxHashMap<asm::InlineAsmReg, usize>,
|
||||
input| {
|
||||
input,
|
||||
r: asm::InlineAsmReg| {
|
||||
match used_regs.entry(r) {
|
||||
Entry::Occupied(o) => {
|
||||
if skip {
|
||||
|
@ -370,7 +371,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let reg_str = |idx| -> &str {
|
||||
// HIR asm doesn't preserve the original alias string of the explicit register,
|
||||
// so we have to retrieve it from AST
|
||||
|
@ -399,13 +399,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}
|
||||
}
|
||||
};
|
||||
let mut overlapping_with = vec![];
|
||||
reg.overlapping_regs(|r| {
|
||||
overlapping_with.push(r);
|
||||
});
|
||||
for r in overlapping_with {
|
||||
if input {
|
||||
check(&mut used_input_regs, true);
|
||||
check(&mut used_input_regs, true, r);
|
||||
}
|
||||
if output {
|
||||
check(&mut used_output_regs, false);
|
||||
check(&mut used_output_regs, false, r);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,12 +425,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let mut output_used = false;
|
||||
let mut overlapping_with = vec![];
|
||||
clobber.overlapping_regs(|reg| {
|
||||
if used_output_regs.contains_key(®) {
|
||||
output_used = true;
|
||||
}
|
||||
overlapping_with.push(reg);
|
||||
});
|
||||
let output_used =
|
||||
overlapping_with.iter().any(|reg| used_output_regs.contains_key(®));
|
||||
|
||||
if !output_used {
|
||||
operands.push((
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue