|
| 1 | +# needs-profiler-support |
| 2 | + |
| 3 | +-include ../tools.mk |
| 4 | + |
| 5 | +# This test makes sure that instrumented binaries record the right counts for |
| 6 | +# functions being called and branches being taken. We run an instrumented binary |
| 7 | +# with an argument that causes a know path through the program and then check |
| 8 | +# that the expected counts get added to the use-phase LLVM IR. |
| 9 | + |
| 10 | +# LLVM doesn't support instrumenting binaries that use SEH: |
| 11 | +# https://github.com/rust-lang/rust/issues/61002 |
| 12 | +# |
| 13 | +# Things work fine with -Cpanic=abort though. |
| 14 | +ifdef IS_MSVC |
| 15 | +COMMON_FLAGS=-Cpanic=abort |
| 16 | +endif |
| 17 | + |
| 18 | +all: |
| 19 | + # We don't compile `opaque` with either optimizations or instrumentation. |
| 20 | + # We don't compile `opaque` with either optimizations or instrumentation. |
| 21 | + $(RUSTC) $(COMMON_FLAGS) opaque.rs |
| 22 | + # Compile the test program with instrumentation |
| 23 | + mkdir -p "$(TMPDIR)"/prof_data_dir |
| 24 | + $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
| 25 | + -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O -Ccodegen-units=1 |
| 26 | + $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O |
| 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 |
| 32 | + $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
| 33 | + -Cprofile-use="$(TMPDIR)"/prof_data_dir/merged.profdata -O \ |
| 34 | + -Ccodegen-units=1 --emit=llvm-ir |
| 35 | + cat "$(TMPDIR)"/interesting.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt |
0 commit comments