Port issue-7349 to a codegen test
This commit is contained in:
parent
a4b11c8e60
commit
476156aedf
@ -131,7 +131,6 @@ run-make/issue-53964/Makefile
|
|||||||
run-make/issue-64153/Makefile
|
run-make/issue-64153/Makefile
|
||||||
run-make/issue-68794-textrel-on-minimal-lib/Makefile
|
run-make/issue-68794-textrel-on-minimal-lib/Makefile
|
||||||
run-make/issue-69368/Makefile
|
run-make/issue-69368/Makefile
|
||||||
run-make/issue-7349/Makefile
|
|
||||||
run-make/issue-83045/Makefile
|
run-make/issue-83045/Makefile
|
||||||
run-make/issue-83112-incr-test-moved-file/Makefile
|
run-make/issue-83112-incr-test-moved-file/Makefile
|
||||||
run-make/issue-84395-lto-embed-bitcode/Makefile
|
run-make/issue-84395-lto-embed-bitcode/Makefile
|
||||||
|
33
tests/codegen/no-redundant-item-monomorphization.rs
Normal file
33
tests/codegen/no-redundant-item-monomorphization.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Test to make sure that inner functions within a polymorphic outer function
|
||||||
|
// don't get re-codegened when the outer function is monomorphized. The test
|
||||||
|
// code monomorphizes the outer functions several times, but the magic constants
|
||||||
|
// used in the inner functions should each appear only once in the generated IR.
|
||||||
|
|
||||||
|
// issue: rust-lang/rust#7349
|
||||||
|
//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0
|
||||||
|
|
||||||
|
// CHECK-COUNT-1: ret i32 8675309
|
||||||
|
// CHECK-COUNT-1: ret i32 11235813
|
||||||
|
|
||||||
|
fn outer<T>() {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn inner() -> u32 {
|
||||||
|
8675309
|
||||||
|
}
|
||||||
|
inner();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" fn outer_foreign<T>() {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn inner() -> u32 {
|
||||||
|
11235813
|
||||||
|
}
|
||||||
|
inner();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
outer::<isize>();
|
||||||
|
outer::<usize>();
|
||||||
|
outer_foreign::<isize>();
|
||||||
|
outer_foreign::<usize>();
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
include ../tools.mk
|
|
||||||
|
|
||||||
# Test to make sure that inner functions within a polymorphic outer function
|
|
||||||
# don't get re-codegened when the outer function is monomorphized. The test
|
|
||||||
# code monomorphizes the outer functions several times, but the magic constants
|
|
||||||
# used in the inner functions should each appear only once in the generated IR.
|
|
||||||
|
|
||||||
all:
|
|
||||||
$(RUSTC) foo.rs --emit=llvm-ir
|
|
||||||
[ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ]
|
|
||||||
[ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ]
|
|
@ -1,22 +0,0 @@
|
|||||||
fn outer<T>() {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn inner() -> u32 {
|
|
||||||
8675309
|
|
||||||
}
|
|
||||||
inner();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn outer_foreign<T>() {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn inner() -> u32 {
|
|
||||||
11235813
|
|
||||||
}
|
|
||||||
inner();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
outer::<isize>();
|
|
||||||
outer::<usize>();
|
|
||||||
outer_foreign::<isize>();
|
|
||||||
outer_foreign::<usize>();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user