2016-12-22 14:27:53 -05: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-03 06:30:28 +09:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2016-12-22 14:27:53 -05:00
|
|
|
// revisions: cfail1 cfail2 cfail3
|
2017-12-04 12:47:16 +01:00
|
|
|
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
|
2016-12-22 14:27:53 -05:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
2020-02-14 16:54:40 +00:00
|
|
|
#![feature(llvm_asm)]
|
2016-12-22 14:27:53 -05:00
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change template
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_template(a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let c: i32;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(c)
|
|
|
|
: "0"(a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
c
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_template(a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let c: i32;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 2, $0"
|
|
|
|
: "=r"(c)
|
|
|
|
: "0"(a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
c
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change output
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_output(a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let mut _out1: i32 = 0;
|
|
|
|
let mut _out2: i32 = 0;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out1)
|
|
|
|
: "0"(a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out1
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_output(a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let mut _out1: i32 = 0;
|
|
|
|
let mut _out2: i32 = 0;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out2)
|
|
|
|
: "0"(a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change input
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_input(_a: i32, _b: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_input(_a: i32, _b: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_b)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change input constraint
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a), "r"(_b)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_input_constraint(_a: i32, _b: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "r"(_a), "0"(_b)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change clobber
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_clobber(_a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_clobber(_a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a)
|
|
|
|
: "eax"
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change options
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(cfail1)]
|
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_options(_a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a)
|
|
|
|
:
|
|
|
|
:
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-07-07 00:35:06 +02:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")]
|
2017-12-05 14:44:52 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2016-12-22 14:27:53 -05:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
2017-12-05 14:44:52 -08:00
|
|
|
pub fn change_options(_a: i32) -> i32 {
|
2016-12-22 14:27:53 -05:00
|
|
|
let _out;
|
|
|
|
unsafe {
|
2020-02-14 16:54:40 +00:00
|
|
|
llvm_asm!("add 1, $0"
|
|
|
|
: "=r"(_out)
|
|
|
|
: "0"(_a)
|
|
|
|
:
|
|
|
|
: "volatile"
|
|
|
|
);
|
2016-12-22 14:27:53 -05:00
|
|
|
}
|
|
|
|
_out
|
|
|
|
}
|