summaryrefslogtreecommitdiffstats
path: root/tests/run-make/coverage-llvmir/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/run-make/coverage-llvmir/Makefile
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/coverage-llvmir/Makefile')
-rw-r--r--tests/run-make/coverage-llvmir/Makefile64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/run-make/coverage-llvmir/Makefile b/tests/run-make/coverage-llvmir/Makefile
new file mode 100644
index 000000000..7be655053
--- /dev/null
+++ b/tests/run-make/coverage-llvmir/Makefile
@@ -0,0 +1,64 @@
+# needs-profiler-support
+
+# Rust coverage maps support LLVM Coverage Mapping Format versions 5 and 6,
+# corresponding with LLVM versions 12 and 13, respectively.
+# When upgrading LLVM versions, consider whether to enforce a minimum LLVM
+# version during testing, with an additional directive at the top of this file
+# that sets, for example: `min-llvm-version: 12.0`
+
+include ../coverage/coverage_tools.mk
+
+BASEDIR=../coverage-llvmir
+
+ifeq ($(UNAME),Darwin)
+ INSTR_PROF_DATA_SUFFIX=,regular,live_support
+ DATA_SECTION_PREFIX=__DATA,
+ LLVM_COV_SECTION_PREFIX=__LLVM_COV,
+ COMDAT_IF_SUPPORTED=
+else
+ INSTR_PROF_DATA_SUFFIX=
+ DATA_SECTION_PREFIX=
+ LLVM_COV_SECTION_PREFIX=
+ COMDAT_IF_SUPPORTED=, comdat
+endif
+
+DEFINE_INTERNAL=define internal
+
+ifdef IS_WINDOWS
+ LLVM_FILECHECK_OPTIONS=\
+ -check-prefixes=CHECK,WINDOWS \
+ -DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
+ -DCOMDAT_IF_SUPPORTED='$(COMDAT_IF_SUPPORTED)' \
+ -DINSTR_PROF_DATA='.lprfd$$M' \
+ -DINSTR_PROF_NAME='.lprfn$$M' \
+ -DINSTR_PROF_CNTS='.lprfc$$M' \
+ -DINSTR_PROF_VALS='.lprfv$$M' \
+ -DINSTR_PROF_VNODES='.lprfnd$$M' \
+ -DINSTR_PROF_COVMAP='.lcovmap$$M' \
+ -DINSTR_PROF_COVFUN='.lcovfun$$M' \
+ -DINSTR_PROF_ORDERFILE='.lorderfile$$M'
+else
+ LLVM_FILECHECK_OPTIONS=\
+ -check-prefixes=CHECK \
+ -DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
+ -DCOMDAT_IF_SUPPORTED='$(COMDAT_IF_SUPPORTED)' \
+ -DINSTR_PROF_DATA='$(DATA_SECTION_PREFIX)__llvm_prf_data$(INSTR_PROF_DATA_SUFFIX)' \
+ -DINSTR_PROF_NAME='$(DATA_SECTION_PREFIX)__llvm_prf_names' \
+ -DINSTR_PROF_CNTS='$(DATA_SECTION_PREFIX)__llvm_prf_cnts' \
+ -DINSTR_PROF_VALS='$(DATA_SECTION_PREFIX)__llvm_prf_vals' \
+ -DINSTR_PROF_VNODES='$(DATA_SECTION_PREFIX)__llvm_prf_vnds' \
+ -DINSTR_PROF_COVMAP='$(LLVM_COV_SECTION_PREFIX)__llvm_covmap' \
+ -DINSTR_PROF_COVFUN='$(LLVM_COV_SECTION_PREFIX)__llvm_covfun' \
+ -DINSTR_PROF_ORDERFILE='$(DATA_SECTION_PREFIX)__llvm_orderfile'
+endif
+
+all: test_llvm_ir
+
+test_llvm_ir:
+ # Compile the test program with non-experimental coverage instrumentation, and generate LLVM IR
+ $(RUSTC) $(BASEDIR)/testprog.rs \
+ -Cinstrument-coverage \
+ --emit=llvm-ir
+
+ cat "$(TMPDIR)"/testprog.ll | \
+ "$(LLVM_FILECHECK)" $(BASEDIR)/filecheck.testprog.txt $(LLVM_FILECHECK_OPTIONS)