]> git.proxmox.com Git - rustc.git/blob - src/test/run-make-fulldeps/pgo-branch-weights/Makefile
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / run-make-fulldeps / pgo-branch-weights / Makefile
1 # needs-profiler-support
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.
6
7 -include ../tools.mk
8
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
18 all:
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