1 # needs-profiler-support
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.
10 # For some very small programs GNU ld seems to not properly handle
11 # instrumentation sections correctly. Neither Gold nor LLD have that problem.
13 ifneq (,$(findstring x86
,$(TARGET
)))
14 COMMON_FLAGS
=-Clink-args
=-fuse-ld
=gold
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