]>
Commit | Line | Data |
---|---|---|
60c5eb7d | 1 | # needs-profiler-support |
1b1a35ee | 2 | # ignore-windows-gnu |
781aab86 | 3 | # ignore-cross-compile |
1b1a35ee XL |
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. | |
60c5eb7d | 7 | |
f2b60f7d | 8 | include ../tools.mk |
60c5eb7d | 9 | |
dfeec247 XL |
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 | ||
60c5eb7d XL |
19 | all: |
20 | # We don't compile `opaque` with either optimizations or instrumentation. | |
dfeec247 | 21 | $(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1 |
60c5eb7d | 22 | # Compile the test program with instrumentation |
dfeec247 | 23 | mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1 |
60c5eb7d | 24 | $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
dfeec247 XL |
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 | |
60c5eb7d XL |
27 | # The argument below generates to the expected branch weights |
28 | $(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1 | |
dfeec247 XL |
29 | "$(LLVM_BIN_DIR)/llvm-profdata" merge \ |
30 | -o "$(TMPDIR)/prof_data_dir/merged.profdata" \ | |
31 | "$(TMPDIR)/prof_data_dir" || exit 1 | |
60c5eb7d | 32 | $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
dfeec247 XL |
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 |