2020-10-19 04:52:15 +00:00
|
|
|
// Ensure inout asm! operands are marked as used by the liveness pass
|
|
|
|
|
2020-10-21 05:34:01 +00:00
|
|
|
//@ only-x86_64
|
2020-10-19 04:52:15 +00:00
|
|
|
//@ check-pass
|
|
|
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
#![warn(unused_assignments)]
|
|
|
|
#![warn(unused_variables)]
|
|
|
|
|
2021-12-10 00:15:33 +00:00
|
|
|
use std::arch::asm;
|
|
|
|
|
2020-10-19 04:52:15 +00:00
|
|
|
// Test the single inout case
|
|
|
|
unsafe fn f1(mut src: *const u8) {
|
|
|
|
asm!("/*{0}*/", inout(reg) src); //~ WARN value assigned to `src` is never read
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn f2(mut src: *const u8) -> *const u8 {
|
|
|
|
asm!("/*{0}*/", inout(reg) src);
|
|
|
|
src
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test the split inout case
|
|
|
|
unsafe fn f3(mut src: *const u8) {
|
|
|
|
asm!("/*{0}*/", inout(reg) src => src); //~ WARN value assigned to `src` is never read
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn f4(mut src: *const u8) -> *const u8 {
|
|
|
|
asm!("/*{0}*/", inout(reg) src => src);
|
|
|
|
src
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests the use of field projections
|
|
|
|
struct S {
|
|
|
|
field: *mut u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn f5(src: &mut S) {
|
|
|
|
asm!("/*{0}*/", inout(reg) src.field);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn f6(src: &mut S) {
|
|
|
|
asm!("/*{0}*/", inout(reg) src.field => src.field);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|