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