1 # needs-profiler-support
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.
9 # For some very small programs GNU ld seems to not properly handle
10 # instrumentation sections correctly. Neither Gold nor LLD have that problem.
12 ifneq (,$(findstring x86,$(TARGET)))
13 COMMON_FLAGS=-Clink-args=-fuse-ld=gold
19 # We don't compile `opaque` with either optimizations or instrumentation.
20 $(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1
21 # Compile the test program with instrumentation
22 mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1
23 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
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
26 # The argument below generates to the expected branch weights
27 $(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1
28 "$(LLVM_BIN_DIR)/llvm-profdata" merge \
29 -o "$(TMPDIR)/prof_data_dir/merged.profdata" \
30 "$(TMPDIR)/prof_data_dir" || exit 1
31 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
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