summaryrefslogtreecommitdiffstats
path: root/src/test/run-make-fulldeps/sepcomp-inlining
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/run-make-fulldeps/sepcomp-inlining
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/run-make-fulldeps/sepcomp-inlining')
-rw-r--r--src/test/run-make-fulldeps/sepcomp-inlining/Makefile15
-rw-r--r--src/test/run-make-fulldeps/sepcomp-inlining/foo.rs30
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/Makefile b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile
new file mode 100644
index 000000000..1d20d9400
--- /dev/null
+++ b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile
@@ -0,0 +1,15 @@
+-include ../tools.mk
+
+# Test that #[inline] functions still get inlined across compilation unit
+# boundaries. Compilation should produce three IR files, but only the two
+# compilation units that have a usage of the #[inline] function should
+# contain a definition. Also, the non-#[inline] function should be defined
+# in only one compilation unit.
+
+all:
+ $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \
+ -Z inline-in-all-cgus
+ [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ]
+ [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ]
+ [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ]
+ [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ]
diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs
new file mode 100644
index 000000000..2fe5f9cb7
--- /dev/null
+++ b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs
@@ -0,0 +1,30 @@
+#![feature(start)]
+
+#[inline]
+fn inlined() -> u32 {
+ 1234
+}
+
+fn normal() -> u32 {
+ 2345
+}
+
+mod a {
+ pub fn f() -> u32 {
+ ::inlined() + ::normal()
+ }
+}
+
+mod b {
+ pub fn f() -> u32 {
+ ::inlined() + ::normal()
+ }
+}
+
+#[start]
+fn start(_: isize, _: *const *const u8) -> isize {
+ a::f();
+ b::f();
+
+ 0
+}