about summary refs log tree commit diff
path: root/tests/codegen/function-return.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-11-30 11:02:40 +0100
committerRalf Jung <post@ralfj.de>2023-11-30 11:02:40 +0100
commit7a661d048ca63c58fe45399ac813f347fa754294 (patch)
tree6ea6290c08709fe4102bdf4dc88f8849cb69f647 /tests/codegen/function-return.rs
parent76ec47782ad310262598c21b618225d718cefbea (diff)
parent2d476222e8458aa873e6760aac189b5e9d0a9930 (diff)
downloadrust-7a661d048ca63c58fe45399ac813f347fa754294.tar.gz
rust-7a661d048ca63c58fe45399ac813f347fa754294.zip
Merge from rustc
Diffstat (limited to 'tests/codegen/function-return.rs')
-rw-r--r--tests/codegen/function-return.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/codegen/function-return.rs b/tests/codegen/function-return.rs
new file mode 100644
index 00000000000..d832d19ac39
--- /dev/null
+++ b/tests/codegen/function-return.rs
@@ -0,0 +1,28 @@
+// Test that the `fn_ret_thunk_extern` function attribute is (not) emitted when
+// the `-Zfunction-return={keep,thunk-extern}` flag is (not) set.
+
+// revisions: unset keep thunk-extern keep-thunk-extern thunk-extern-keep
+// needs-llvm-components: x86
+// compile-flags: --target x86_64-unknown-linux-gnu
+// [keep] compile-flags: -Zfunction-return=keep
+// [thunk-extern] compile-flags: -Zfunction-return=thunk-extern
+// [keep-thunk-extern] compile-flags: -Zfunction-return=keep -Zfunction-return=thunk-extern
+// [thunk-extern-keep] compile-flags: -Zfunction-return=thunk-extern -Zfunction-return=keep
+
+#![crate_type = "lib"]
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[no_mangle]
+pub fn foo() {
+    // CHECK: @foo() unnamed_addr #0
+
+    // unset-NOT: fn_ret_thunk_extern
+    // keep-NOT: fn_ret_thunk_extern
+    // thunk-extern: attributes #0 = { {{.*}}fn_ret_thunk_extern{{.*}} }
+    // keep-thunk-extern: attributes #0 = { {{.*}}fn_ret_thunk_extern{{.*}} }
+    // thunk-extern-keep-NOT: fn_ret_thunk_extern
+}