Skip to content

Commit c50c492

Browse files
committed
Introduce test/llvm-cov/Inputs/yaml.makefile for convenience.
1 parent 97a4a8f commit c50c492

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# This is for developers' convenience and not expected to be in build steps.
2+
#
3+
# Usage:
4+
# cd /path/to/llvm-project/llvm/test/tools/llvm-cov/Inputs
5+
# PATH=/path/to/build/bin:$PATH make -f yaml.makefile
6+
7+
CFLAGS_COVMAP = -fcoverage-compilation-dir=. \
8+
-mllvm -runtime-counter-relocation=true \
9+
-mllvm -conditional-counter-update=true \
10+
-mllvm -enable-name-compression=false \
11+
-fprofile-instr-generate -fcoverage-mapping \
12+
$(if $(filter mcdc-%, $*), $(CFLAGS_MCDC))
13+
14+
CFLAGS_MCDC = -fcoverage-mcdc
15+
16+
%.o: %.cpp
17+
clang++ $< -c -o $@ $(CFLAGS_COVMAP)
18+
19+
%.o: %.c
20+
clang $< -c -o $@ $(CFLAGS_COVMAP)
21+
22+
%-single.o: %.cpp
23+
clang++ $< -c -o $@ \
24+
-mllvm -enable-single-byte-coverage=true \
25+
$(CFLAGS_COVMAP)
26+
27+
%-single.o: %.c
28+
clang $< -c -o $@ \
29+
-mllvm -enable-single-byte-coverage=true \
30+
$(CFLAGS_COVMAP)
31+
32+
%.covmap.o: %.o
33+
llvm-objcopy \
34+
--only-section=__llvm_covfun \
35+
--only-section=__llvm_covmap \
36+
--only-section=__llvm_prf_names \
37+
--strip-unneeded \
38+
$< $@
39+
40+
%.yaml: %.covmap.o
41+
obj2yaml $< > $@
42+
43+
%.exe: %.o
44+
clang++ -fprofile-instr-generate $^ -o $@
45+
46+
ARGS_branch-logical-mixed := \
47+
0 0; \
48+
0 1; \
49+
1 0; \
50+
1 1
51+
52+
ARGS_branch-macros := \
53+
0 1; \
54+
1 0; \
55+
1 1
56+
57+
ARGS_branch-showBranchPercentage := \
58+
0 1; \
59+
1 1; \
60+
2 2; \
61+
4 0; \
62+
5 0; \
63+
1
64+
65+
ARGS_showLineExecutionCounts := $(patsubst %,%;,$(shell seq 161))
66+
67+
ARGS_mcdc-const-folding := \
68+
0 1; \
69+
1 0; \
70+
1 1; \
71+
1 1
72+
73+
%.profdata: %.exe
74+
-find -name '$*.*.profraw' | xargs rm -fv
75+
@if [ "$(ARGS_$(patsubst %-single,%,$*))" = "" ]; then \
76+
echo "Executing: $<"; \
77+
LLVM_PROFILE_FILE=$*.%p%c.profraw ./$<; \
78+
else \
79+
LLVM_PROFILE_FILE=$*.%p%c.profraw; \
80+
export LLVM_PROFILE_FILE; \
81+
for xcmd in $(shell echo "$(ARGS_$(patsubst %-single,%,$*))" | tr ';[:blank:]' ' %'); do \
82+
cmd=$$(echo "$$xcmd" | tr '%' ' '); \
83+
echo "Executing series: $< $$cmd"; \
84+
eval "./$< $$cmd"; \
85+
done; \
86+
fi
87+
find -name '$*.*.profraw' | xargs llvm-profdata merge --sparse -o $@
88+
89+
%.proftext: %.profdata
90+
llvm-profdata merge --text -o $@ $<
91+
92+
.PHONY: all
93+
all: \
94+
$(patsubst %.yaml,%.proftext, $(wildcard *.yaml)) \
95+
$(wildcard *.yaml)
96+
-find -name '*.profraw' | xargs rm -f

0 commit comments

Comments
 (0)