|
| 1 | +# needs-profiler-support |
| 2 | + |
| 3 | +-include ../tools.mk |
| 4 | + |
| 5 | +# This test makes sure that indirect call promotion is performed. The test |
| 6 | +# programs calls the same function a thousand times through a function pointer. |
| 7 | +# Only PGO data provides the information that it actually always is the same |
| 8 | +# function. We verify that the indirect call promotion pass inserts a check |
| 9 | +# whether it can make a direct call instead of the indirect call. |
| 10 | + |
| 11 | +# LLVM doesn't support instrumenting binaries that use SEH: |
| 12 | +# https://github.com/rust-lang/rust/issues/61002 |
| 13 | +# |
| 14 | +# Things work fine with -Cpanic=abort though. |
| 15 | +ifdef IS_MSVC |
| 16 | +COMMON_FLAGS=-Cpanic=abort |
| 17 | +endif |
| 18 | + |
| 19 | +all: |
| 20 | + # We don't compile `opaque` with either optimizations or instrumentation. |
| 21 | + # We don't compile `opaque` with either optimizations or instrumentation. |
| 22 | + $(RUSTC) $(COMMON_FLAGS) opaque.rs |
| 23 | + # Compile the test program with instrumentation |
| 24 | + mkdir -p "$(TMPDIR)"/prof_data_dir |
| 25 | + $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
| 26 | + -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O -Ccodegen-units=1 |
| 27 | + $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O |
| 28 | + # The argument below generates to the expected branch weights |
| 29 | + $(call RUN,main) || exit 1 |
| 30 | + "$(LLVM_BIN_DIR)"/llvm-profdata merge \ |
| 31 | + -o "$(TMPDIR)"/prof_data_dir/merged.profdata \ |
| 32 | + "$(TMPDIR)"/prof_data_dir |
| 33 | + $(RUSTC) $(COMMON_FLAGS) interesting.rs \ |
| 34 | + -Cprofile-use="$(TMPDIR)"/prof_data_dir/merged.profdata -O \ |
| 35 | + -Ccodegen-units=1 --emit=llvm-ir |
| 36 | + cat "$(TMPDIR)"/interesting.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt |
0 commit comments