forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the
no-builtins
attribute to functions when no_builtins
is ap…
…plied 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.
- Loading branch information
Showing
8 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include ../tools.mk | ||
|
||
# We want to check if `no-builtins` is also added to the function declarations in the used crate. | ||
|
||
all: | ||
$(RUSTC) no_builtins.rs --emit=link | ||
$(RUSTC) main.rs --emit=llvm-ir | ||
|
||
cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CHECK: declare void @foo() | ||
CHECK-SAME: #[[ATTR_3:[0-9]+]] | ||
|
||
CHECK: attributes #[[ATTR_3]] | ||
CHECK-SAME: no-builtins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extern crate no_builtins; | ||
|
||
#[no_mangle] | ||
fn call_foo() { | ||
no_builtins::foo(); | ||
} | ||
|
||
fn main() { | ||
call_foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![crate_type = "lib"] | ||
#![no_builtins] | ||
|
||
#[no_mangle] | ||
pub fn foo() {} |