Skip to content

Commit bc8a521

Browse files
committed
Fix pgo tests
1 parent 075ce31 commit bc8a521

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

src/tools/run-make-support/src/external_deps/rustc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ impl Rustc {
405405
};
406406
self
407407
}
408+
409+
/// Make that the generated LLVM IR is in source order.
410+
pub fn codegen_source_order(&mut self) -> &mut Self {
411+
self.cmd.arg("-Zcodegen-source-order");
412+
self
413+
}
408414
}
409415

410416
/// Query the sysroot path corresponding `rustc --print=sysroot`.

tests/run-make/pgo-branch-weights/rmake.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc}
1717
fn main() {
1818
let path_prof_data_dir = Path::new("prof_data_dir");
1919
let path_merged_profdata = path_prof_data_dir.join("merged.profdata");
20-
rustc().input("opaque.rs").run();
20+
rustc().input("opaque.rs").codegen_source_order().run();
2121
rfs::create_dir_all(&path_prof_data_dir);
2222
rustc()
2323
.input("interesting.rs")
2424
.profile_generate(&path_prof_data_dir)
2525
.opt()
2626
.codegen_units(1)
27+
.codegen_source_order()
28+
.run();
29+
rustc()
30+
.input("main.rs")
31+
.profile_generate(&path_prof_data_dir)
32+
.opt()
33+
.codegen_source_order()
2734
.run();
28-
rustc().input("main.rs").profile_generate(&path_prof_data_dir).opt().run();
2935
run_with_args("main", &["aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc"]);
3036
llvm_profdata().merge().output(&path_merged_profdata).input(path_prof_data_dir).run();
3137
rustc()
@@ -34,6 +40,7 @@ fn main() {
3440
.opt()
3541
.codegen_units(1)
3642
.emit("llvm-ir")
43+
.codegen_source_order()
3744
.run();
3845
llvm_filecheck()
3946
.patterns("filecheck-patterns.txt")

tests/run-make/pgo-indirect-call-promotion/rmake.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run, rustc};
1414

1515
fn main() {
1616
// We don't compile `opaque` with either optimizations or instrumentation.
17-
rustc().input("opaque.rs").run();
17+
rustc().input("opaque.rs").codegen_source_order().run();
1818
// Compile the test program with instrumentation
1919
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();
20+
rustc()
21+
.input("interesting.rs")
22+
.profile_generate("prof_data_dir")
23+
.opt()
24+
.codegen_units(1)
25+
.codegen_source_order()
26+
.run();
27+
rustc().input("main.rs").profile_generate("prof_data_dir").opt().codegen_source_order().run();
2228
// The argument below generates to the expected branch weights
2329
run("main");
2430
llvm_profdata().merge().output("prof_data_dir/merged.profdata").input("prof_data_dir").run();
@@ -28,6 +34,7 @@ fn main() {
2834
.opt()
2935
.codegen_units(1)
3036
.emit("llvm-ir")
37+
.codegen_source_order()
3138
.run();
3239
llvm_filecheck()
3340
.patterns("filecheck-patterns.txt")

tests/run-make/pgo-use/rmake.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn main() {
2222
.opt_level("2")
2323
.codegen_units(1)
2424
.arg("-Cllvm-args=-disable-preinline")
25+
.codegen_source_order()
2526
.profile_generate(cwd())
2627
.input("main.rs")
2728
.run();
@@ -40,6 +41,7 @@ fn main() {
4041
.arg("-Cllvm-args=-disable-preinline")
4142
.profile_use("merged.profdata")
4243
.emit("llvm-ir")
44+
.codegen_source_order()
4345
.input("main.rs")
4446
.run();
4547
// Check that the generate IR contains some things that we expect.

0 commit comments

Comments
 (0)