about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorDianQK <dianqk@dianqk.net>2023-07-18 22:15:47 +0800
committerDianQK <dianqk@dianqk.net>2023-07-18 22:15:47 +0800
commitcc08749df2613c17c8c2e9d8224a24a24c126423 (patch)
tree26f2f5b85d4c03d84204d24899e2e84dd800b5cc /tests/codegen
parentf0580df0d53d67ad5c7f85756eb9f221566e4fb0 (diff)
downloadrust-cc08749df2613c17c8c2e9d8224a24a24c126423.tar.gz
rust-cc08749df2613c17c8c2e9d8224a24a24c126423.zip
Add the `no-builtins` attribute to functions when `no_builtins` is applied at the crate level.
When `no_builtins` is applied at the crate level, we should add the
`no-builtins` attribute to each function to ensure it takes effect in LTO.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/no_builtins-at-crate.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/codegen/no_builtins-at-crate.rs b/tests/codegen/no_builtins-at-crate.rs
new file mode 100644
index 00000000000..02ed670900e
--- /dev/null
+++ b/tests/codegen/no_builtins-at-crate.rs
@@ -0,0 +1,24 @@
+// compile-flags: -C opt-level=1
+
+#![no_builtins]
+#![crate_type = "lib"]
+
+// CHECK: define
+// CHECK-SAME: @__aeabi_memcpy
+// CHECK-SAME: #0
+#[no_mangle]
+pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, size: usize) {
+    // CHECK: call
+    // CHECK-SAME: @memcpy(
+    memcpy(dest, src, size);
+}
+
+// CHECK: declare
+// CHECK-SAME: @memcpy
+// CHECK-SAME: #0
+extern "C" {
+    pub fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8;
+}
+
+// CHECK: attributes #0
+// CHECK-SAME: "no-builtins"