Skip to content

Commit 76c5149

Browse files
committed
rewrite pgo-indirect-call-promotion to rmake
1 parent 9fae59a commit 76c5149

File tree

5 files changed

+46
-40
lines changed

5 files changed

+46
-40
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
@@ -33,7 +33,6 @@ run-make/min-global-align/Makefile
3333
run-make/native-link-modifier-bundle/Makefile
3434
run-make/no-alloc-shim/Makefile
3535
run-make/pgo-gen-lto/Makefile
36-
run-make/pgo-indirect-call-promotion/Makefile
3736
run-make/print-calling-conventions/Makefile
3837
run-make/print-target-list/Makefile
3938
run-make/raw-dylib-alt-calling-convention/Makefile

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

+12-16
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,15 @@ 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 = [
22-
r#""main.rs""#,
23-
r#""-g""#,
24-
r#""--crate-name""#,
25-
r#""my_crate_name""#,
26-
r#""--crate-type""#,
27-
r#""bin""#,
28-
r#""-C""#,
29-
r#""metadata=dc9ef878b0a48666""#,
30-
r#""--out-dir""#,
31-
];
32-
for string in strings {
33-
assert_contains(rfs::read_to_string("my_crate_name.pdb"), string);
34-
}
20+
use bstr::ByteSlice;
21+
assert!(&rfs::read("my_crate_name.pdb").find(env_var("RUSTC").as_bytes()).is_some());
22+
assert!(&rfs::read("my_crate_name.pdb").find(br#""main.rs""#).is_some());
23+
assert!(&rfs::read("my_crate_name.pdb").find(br#""-g""#).is_some());
24+
assert!(&rfs::read("my_crate_name.pdb").find(br#""--crate-name""#).is_some());
25+
assert!(&rfs::read("my_crate_name.pdb").find(br#""my_crate_name""#).is_some());
26+
assert!(&rfs::read("my_crate_name.pdb").find(br#""--crate-type""#).is_some());
27+
assert!(&rfs::read("my_crate_name.pdb").find(br#""bin""#).is_some());
28+
assert!(&rfs::read("my_crate_name.pdb").find(br#""-C""#).is_some());
29+
assert!(&rfs::read("my_crate_name.pdb").find(br#""metadata=dc9ef878b0a48666""#).is_some());
30+
assert!(&rfs::read("my_crate_name.pdb").find(br#""--out-dir""#).is_some());
3531
}

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)