-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The embedded bitcode should always be prepared for LTO/ThinLTO
- Loading branch information
Showing
9 changed files
with
190 additions
and
50 deletions.
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
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,10 @@ | ||
#![crate_name = "interesting"] | ||
#![crate_type = "rlib"] | ||
|
||
extern crate opaque; | ||
|
||
#[no_mangle] | ||
#[inline(never)] | ||
pub fn function_called_once() { | ||
opaque::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 @@ | ||
extern crate interesting; | ||
|
||
fn main() { | ||
interesting::function_called_once(); | ||
} |
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_name = "opaque"] | ||
#![crate_type = "rlib"] | ||
|
||
#[inline(never)] | ||
pub fn 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,42 @@ | ||
// This test case verifies that we successfully complete an LTO build with PGO | ||
// using the embedded bitcode. | ||
// It also ensures that the generated IR correctly includes the call results. | ||
|
||
//@ needs-profiler-runtime | ||
//@ ignore-cross-compile | ||
|
||
use std::path::Path; | ||
|
||
use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run, rustc}; | ||
|
||
fn main() { | ||
let path_prof_data_dir = Path::new("prof_data_dir"); | ||
let path_merged_profdata = path_prof_data_dir.join("merged.profdata"); | ||
rustc().input("opaque.rs").codegen_units(1).run(); | ||
rfs::create_dir_all(&path_prof_data_dir); | ||
rustc() | ||
.input("interesting.rs") | ||
.profile_generate(&path_prof_data_dir) | ||
.opt() | ||
.codegen_units(1) | ||
.run(); | ||
rustc() | ||
.input("main.rs") | ||
.arg("-Clto=thin") | ||
.opt() | ||
.codegen_units(1) | ||
.profile_generate(&path_prof_data_dir) | ||
.opt() | ||
.run(); | ||
run("main"); | ||
llvm_profdata().merge().output(&path_merged_profdata).input(path_prof_data_dir).run(); | ||
rustc().input("interesting.rs").profile_use(&path_merged_profdata).opt().codegen_units(1).run(); | ||
rustc() | ||
.input("main.rs") | ||
.arg("-Clto=thin") | ||
.opt() | ||
.codegen_units(1) | ||
.profile_use(&path_merged_profdata) | ||
.opt() | ||
.run(); | ||
} |