2016-12-22 13:27:53 -06:00
|
|
|
// This test case tests the incremental compilation hash (ICH) implementation
|
|
|
|
// for inline asm.
|
|
|
|
|
|
|
|
// The general pattern followed here is: Change one thing between rev1 and rev2
|
|
|
|
// and make sure that the hash has changed, then change nothing between rev2 and
|
|
|
|
// rev3 and make sure that the hash has not changed.
|
|
|
|
|
2019-07-02 16:30:28 -05:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2021-04-22 14:33:16 -05:00
|
|
|
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
|
2022-05-27 20:17:39 -05:00
|
|
|
// compile-flags: -Z query-dep-graph -O
|
2021-12-29 08:14:50 -06:00
|
|
|
// needs-asm-support
|
2021-04-22 14:33:16 -05:00
|
|
|
// [cfail1]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail2]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail3]compile-flags: -Zincremental-ignore-spans
|
2016-12-22 13:27:53 -06:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
2022-01-11 18:00:00 -06:00
|
|
|
use std::arch::asm;
|
2016-12-22 13:27:53 -06:00
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change template
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2022-01-11 18:00:00 -06:00
|
|
|
pub fn change_template(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let c: i32;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, 1",
|
|
|
|
out(reg) c
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
c
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2022-01-11 18:00:00 -06:00
|
|
|
pub fn change_template(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let c: i32;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, 2",
|
|
|
|
out(reg) c
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
c
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change output
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_output(a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let mut _out1: i32 = 0;
|
|
|
|
let mut _out2: i32 = 0;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out1,
|
|
|
|
in(reg) a
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out1
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_output(a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let mut _out1: i32 = 0;
|
|
|
|
let mut _out2: i32 = 0;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out2,
|
|
|
|
in(reg) a
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change input
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_input(_a: i32, _b: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_input(_a: i32, _b: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _b
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change input constraint
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
in("eax") _b);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
in("ecx") _b);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change clobber
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_clobber(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
lateout("ecx") _
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_clobber(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
lateout("edx") _
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change options
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_options(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
options(readonly),
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 16:44:52 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-12-22 13:27:53 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 16:44:52 -06:00
|
|
|
pub fn change_options(_a: i32) -> i32 {
|
2016-12-22 13:27:53 -06:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2022-01-11 18:00:00 -06:00
|
|
|
asm!("mov {0}, {1}",
|
|
|
|
out(reg) _out,
|
|
|
|
in(reg) _a,
|
|
|
|
options(nomem ),
|
|
|
|
);
|
2016-12-22 13:27:53 -06:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|