Skip to content

Commit 7d1a97f

Browse files
committed
rewrite pgo-indirect-call-promotion to rmake
1 parent 7e5a2ea commit 7d1a97f

File tree

5 files changed

+46
-32
lines changed

5 files changed

+46
-32
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
204204
"only-watchos",
205205
"only-windows",
206206
"only-windows-gnu",
207+
"only-windows-msvc",
207208
"only-x86",
208209
"only-x86_64",
209210
"only-x86_64-fortanix-unknown-sgx",

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ run-make/macos-deployment-target/Makefile
1616
run-make/min-global-align/Makefile
1717
run-make/native-link-modifier-bundle/Makefile
1818
run-make/no-alloc-shim/Makefile
19-
run-make/pgo-indirect-call-promotion/Makefile
2019
run-make/remap-path-prefix-dwarf/Makefile
2120
run-make/reproducible-build/Makefile
2221
run-make/rlib-format-packed-bundled-libs/Makefile

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

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@ only-windows-msvc
88
// Reason: pdb files are unique to this architecture
99

10-
use run_make_support::{assert_contains, env_var, rfs, rustc};
10+
use run_make_support::{assert_contains, bstr, env_var, rfs, rustc};
1111

1212
fn main() {
1313
rustc()
@@ -17,19 +17,23 @@ 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"));
21-
let strings = [
20+
let tests = [
21+
&env_var("RUSTC"),
2222
r#""main.rs""#,
2323
r#""-g""#,
2424
r#""--crate-name""#,
2525
r#""my_crate_name""#,
2626
r#""--crate-type""#,
2727
r#""bin""#,
28-
r#""-C""#,
29-
r#""metadata=dc9ef878b0a48666""#,
30-
r#""--out-dir""#,
28+
r#""-Cmetadata=dc9ef878b0a48666""#,
3129
];
32-
for string in strings {
33-
assert_contains(rfs::read_to_string("my_crate_name.pdb"), string);
30+
for test in tests {
31+
assert_pdb_contains(test);
3432
}
3533
}
34+
35+
fn assert_pdb_contains(needle: &str) {
36+
let needle = needle.as_bytes();
37+
use bstr::ByteSlice;
38+
assert!(&rfs::read("my_crate_name.pdb").find(needle).is_some());
39+
}

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)