]>
Commit | Line | Data |
---|---|---|
1 | # needs-profiler-support | |
2 | # ignore-windows-gnu | |
3 | # ignore-cross-compile | |
4 | ||
5 | # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works | |
6 | # properly. Since we only have GCC on the CI ignore the test for now. | |
7 | ||
8 | include ../tools.mk | |
9 | ||
10 | # For some very small programs GNU ld seems to not properly handle | |
11 | # instrumentation sections correctly. Neither Gold nor LLD have that problem. | |
12 | ifeq ($(UNAME),Linux) | |
13 | ifneq (,$(findstring x86,$(TARGET))) | |
14 | COMMON_FLAGS=-Clink-args=-fuse-ld=gold | |
15 | endif | |
16 | endif | |
17 | ||
18 | ||
19 | all: | |
20 | # We don't compile `opaque` with either optimizations or instrumentation. | |
21 | $(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1 | |
22 | # Compile the test program with instrumentation | |
23 | mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1 | |
24 | $(RUSTC) $(COMMON_FLAGS) interesting.rs \ | |
25 | -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O -Ccodegen-units=1 || exit 1 | |
26 | $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O || exit 1 | |
27 | # The argument below generates to the expected branch weights | |
28 | $(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1 | |
29 | "$(LLVM_BIN_DIR)/llvm-profdata" merge \ | |
30 | -o "$(TMPDIR)/prof_data_dir/merged.profdata" \ | |
31 | "$(TMPDIR)/prof_data_dir" || exit 1 | |
32 | $(RUSTC) $(COMMON_FLAGS) interesting.rs \ | |
33 | -Cprofile-use="$(TMPDIR)/prof_data_dir/merged.profdata" -O \ | |
34 | -Ccodegen-units=1 --emit=llvm-ir || exit 1 | |
35 | cat "$(TMPDIR)/interesting.ll" | "$(LLVM_FILECHECK)" filecheck-patterns.txt |