Mark inout asm! operands as used in liveness pass

This commit is contained in:
Olivia Crain 2020-10-15 08:40:40 -05:00
parent ffeeb20398
commit cc0b718aaa
2 changed files with 37 additions and 1 deletions

View File

@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
hir::InlineAsmOperand::InOut { expr, .. } => {
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE);
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE);
}
hir::InlineAsmOperand::SplitInOut { out_expr, .. } => {
if let Some(expr) = out_expr {

View File

@ -0,0 +1,36 @@
// Ensure inout asm! operands are marked as used by the liveness pass
// only-x86_64
// check-pass
#![feature(asm)]
#![allow(dead_code)]
#![deny(unused_variables)]
// Tests the single variable inout case
unsafe fn rep_movsb(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 {
while n != 0 {
asm!(
"rep movsb",
inout("rcx") n,
inout("rsi") src,
inout("rdi") dest,
);
}
dest
}
// Tests the split inout case
unsafe fn rep_movsb2(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 {
while n != 0 {
asm!(
"rep movsb",
inout("rcx") n,
inout("rsi") src => src,
inout("rdi") dest,
);
}
dest
}
fn main() {}