diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2025-04-17 18:28:52 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2025-04-17 18:05:17 +0000 |
commit | d85328baf00510fce8b5d3843f731023e12944b1 (patch) | |
tree | fb29fa62ec21a619c2054a70ce1b7ad371479edf /gcc | |
parent | 78fcf63b606343f6fe837b933b8fadccf0f49e87 (diff) | |
download | gcc-d85328baf00510fce8b5d3843f731023e12944b1.zip gcc-d85328baf00510fce8b5d3843f731023e12944b1.tar.gz gcc-d85328baf00510fce8b5d3843f731023e12944b1.tar.bz2 |
Add gimple test for black box intrinsic
gcc/testsuite/ChangeLog:
* rust/compile/black_box.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/compile/black_box.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/black_box.rs b/gcc/testsuite/rust/compile/black_box.rs new file mode 100644 index 0000000..80615af --- /dev/null +++ b/gcc/testsuite/rust/compile/black_box.rs @@ -0,0 +1,28 @@ +// { dg-options "-fdump-tree-gimple" } +#![feature(rustc_attrs)] + +#[lang = "sized"] +pub trait Sized {} + +#[rustc_builtin_macro] +macro_rules! llvm_asm { + () => {}; +} + +pub fn black_box<T>(mut dummy: T) -> T { + unsafe { + // { dg-final { scan-tree-dump-times {memory} 1 gimple } } + llvm_asm!("" : : "r"(&mut dummy) : "memory" : "volatile"); + } + + dummy +} + +fn my_function(a: i32) -> i32 { + a +} + +fn main() { + let dummy: i32 = 42; + let _ = black_box(my_function(dummy)); +} |