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