Skip to content

Commit c474342

Browse files
committed
rewrite pgo-indirect-call-promotion to rmake
1 parent 538cdd4 commit c474342

File tree

5 files changed

+36
-26
lines changed

5 files changed

+36
-26
lines changed

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
202202
"only-watchos",
203203
"only-windows",
204204
"only-windows-gnu",
205+
"only-windows-msvc",
205206
"only-x86",
206207
"only-x86_64",
207208
"only-x86_64-fortanix-unknown-sgx",

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ run-make/native-link-modifier-whole-archive/Makefile
3535
run-make/no-alloc-shim/Makefile
3636
run-make/no-builtins-attribute/Makefile
3737
run-make/pgo-gen-lto/Makefile
38-
run-make/pgo-indirect-call-promotion/Makefile
3938
run-make/print-calling-conventions/Makefile
4039
run-make/print-target-list/Makefile
4140
run-make/raw-dylib-alt-calling-convention/Makefile

tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
.crate_type("bin")
1818
.metadata("dc9ef878b0a48666")
1919
.run();
20-
assert_contains(rfs::read_to_string("my_crate_name.pdb"), env_var("RUSTC_ORIGINAL"));
20+
assert_contains(String::from_utf8_lossy(&rfs::read("my_crate_name.pdb")), env_var("RUSTC"));
2121
let strings = [
2222
r#""main.rs""#,
2323
r#""-g""#,
@@ -30,6 +30,6 @@ fn main() {
3030
r#""--out-dir""#,
3131
];
3232
for string in strings {
33-
assert_contains(rfs::read_to_string("my_crate_name.pdb"), string);
33+
assert_contains(String::from_utf8_lossy(&rfs::read("my_crate_name.pdb")), string);
3434
}
3535
}

tests/run-make/pgo-indirect-call-promotion/Makefile

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This test checks that indirect call promotion is performed. The test
2+
// programs calls the same function a thousand times through a function pointer.
3+
// Only PGO data provides the information that it actually always is the same
4+
// function. We verify that the indirect call promotion pass inserts a check
5+
// whether it can make a direct call instead of the indirect call.
6+
// See https://github.com/rust-lang/rust/pull/66631
7+
8+
//@ needs-profiler-support
9+
// Reason: llvm_profdata is used
10+
//@ ignore-cross-compile
11+
// Reason: the compiled binary is executed
12+
13+
use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run, rustc};
14+
15+
fn main() {
16+
// We don't compile `opaque` with either optimizations or instrumentation.
17+
rustc().input("opaque.rs").run();
18+
// Compile the test program with instrumentation
19+
rfs::create_dir("prof_data_dir");
20+
rustc().input("interesting.rs").profile_generate("prof_data_dir").opt().codegen_units(1).run();
21+
rustc().input("main.rs").profile_generate("prof_data_dir").opt().run();
22+
// The argument below generates to the expected branch weights
23+
run("main");
24+
llvm_profdata().merge().output("prof_data_dir/merged.profdata").input("prof_data_dir").run();
25+
rustc()
26+
.input("interesting.rs")
27+
.profile_use("prof_data_dir/merged.profdata")
28+
.opt()
29+
.codegen_units(1)
30+
.emit("llvm-ir")
31+
.run();
32+
llvm_filecheck().patterns("filecheck-patterns.txt").stdin(rfs::read("interesting.ll")).run();
33+
}

0 commit comments

Comments
 (0)