From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/run-make-fulldeps/pgo-use/Makefile | 46 ---------------------- .../pgo-use/filecheck-patterns.txt | 11 ------ src/test/run-make-fulldeps/pgo-use/main.rs | 23 ----------- 3 files changed, 80 deletions(-) delete mode 100644 src/test/run-make-fulldeps/pgo-use/Makefile delete mode 100644 src/test/run-make-fulldeps/pgo-use/filecheck-patterns.txt delete mode 100644 src/test/run-make-fulldeps/pgo-use/main.rs (limited to 'src/test/run-make-fulldeps/pgo-use') diff --git a/src/test/run-make-fulldeps/pgo-use/Makefile b/src/test/run-make-fulldeps/pgo-use/Makefile deleted file mode 100644 index 3bac9b77a..000000000 --- a/src/test/run-make-fulldeps/pgo-use/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# needs-profiler-support -# ignore-windows-gnu - -# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works -# properly. Since we only have GCC on the CI ignore the test for now. - -include ../tools.mk - -# This test makes sure that PGO profiling data leads to cold functions being -# marked as `cold` and hot functions with `inlinehint`. -# The test program contains an `if` were actual execution only ever takes the -# `else` branch. Accordingly, we expect the function that is never called to -# be marked as cold. -# -# Disable the pre-inlining pass (i.e. a pass that does some inlining before -# it adds the profiling instrumentation). Disabling this pass leads to -# rather predictable IR which we need for this test to be stable. - -COMMON_FLAGS=-Copt-level=2 -Ccodegen-units=1 -Cllvm-args=-disable-preinline - -ifeq ($(UNAME),Darwin) -# macOS does not have the `tac` command, but `tail -r` does the same thing -TAC := tail -r -else -# some other platforms don't support the `-r` flag for `tail`, so use `tac` -TAC := tac -endif - -all: - # Compile the test program with instrumentation - $(RUSTC) $(COMMON_FLAGS) -Cprofile-generate="$(TMPDIR)" main.rs - # Run it in order to generate some profiling data - $(call RUN,main some-argument) || exit 1 - # Postprocess the profiling data so it can be used by the compiler - "$(LLVM_BIN_DIR)"/llvm-profdata merge \ - -o "$(TMPDIR)"/merged.profdata \ - "$(TMPDIR)"/default_*.profraw - # Compile the test program again, making use of the profiling data - $(RUSTC) $(COMMON_FLAGS) -Cprofile-use="$(TMPDIR)"/merged.profdata --emit=llvm-ir main.rs - # Check that the generate IR contains some things that we expect - # - # We feed the file into LLVM FileCheck tool *in reverse* so that we see the - # line with the function name before the line with the function attributes. - # FileCheck only supports checking that something matches on the next line, - # but not if something matches on the previous line. - $(TAC) "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt diff --git a/src/test/run-make-fulldeps/pgo-use/filecheck-patterns.txt b/src/test/run-make-fulldeps/pgo-use/filecheck-patterns.txt deleted file mode 100644 index 6da34f88f..000000000 --- a/src/test/run-make-fulldeps/pgo-use/filecheck-patterns.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Add a check that the IR contains some expected metadata -CHECK: !{!"ProfileFormat", !"InstrProf"} -CHECK: !"ProfileSummary" - -# Make sure that the hot function is marked with `inlinehint` -CHECK: define {{.*}} @hot_function -CHECK-NEXT: Function Attrs:{{.*}}inlinehint - -# Make sure that the cold function is marked with `cold` -CHECK: define {{.*}} @cold_function -CHECK-NEXT: Function Attrs:{{.*}}cold diff --git a/src/test/run-make-fulldeps/pgo-use/main.rs b/src/test/run-make-fulldeps/pgo-use/main.rs deleted file mode 100644 index eb9192c87..000000000 --- a/src/test/run-make-fulldeps/pgo-use/main.rs +++ /dev/null @@ -1,23 +0,0 @@ -#[no_mangle] -pub fn cold_function(c: u8) { - println!("cold {}", c); -} - -#[no_mangle] -pub fn hot_function(c: u8) { - std::env::set_var(format!("var{}", c), format!("hot {}", c)); -} - -fn main() { - let arg = std::env::args().skip(1).next().unwrap(); - - for i in 0 .. 1000_000 { - let some_value = arg.as_bytes()[i % arg.len()]; - if some_value == b'!' { - // This branch is never taken at runtime - cold_function(some_value); - } else { - hot_function(some_value); - } - } -} -- cgit v1.2.3