aboutsummaryrefslogtreecommitdiff
path: root/TEST.optllcdbg.Makefile
blob: dd5c06a3f0c2e9233631ba3a2e472ced635d7b57 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
##===- TEST.optllcdbg.Makefile -----------------------------*- Makefile -*-===##
#
# This test checks whether presence of debug declarations influences
# the code generator or not.
#
# If input.bc includes llvm.dbg intrinsics and llvm.dbg variables then
# the code in first.s and second.s should match. Otherwise debugging information
# is influencing the code generator.  The Dwarf info in first.s and second.s is
# normally quite different, so the data directives that appear in Dwarf are
# stripped out before comparison.
#
# This has only been used on Darwin; the data directives to strip and grep magic
# might be different elsewhere.
#
##===----------------------------------------------------------------------===##

CURDIR  := $(shell cd .; pwd)
PROGDIR := $(PROJ_SRC_ROOT)
RELDIR  := $(subst $(PROGDIR),,$(CURDIR))

TESTNAME = $*
TEST_TARGET_FLAGS = -g -O0
LLC_DEBUG_FLAGS = -O3 $(LLCFLAGS)
OPT_FLAGS = -O3
.PRECIOUS: Output/%.first.s Output/%.second.s Output/%.t2c.s Output/%.t1c.s Output/%.t2b.bc Output/%.t1b.bc Output/%.t1a.bc Output/%.t2a.bc

$(PROGRAMS_TO_TEST:%=test.$(TEST).%): \
test.$(TEST).%: Output/%.$(TEST).report.txt
	@-cat $<

$(PROGRAMS_TO_TEST:%=Output/%.optllcdbg.report.txt): \
Output/%.optllcdbg.report.txt: Output/%.report.diff
	@echo > $@
	@echo "---------------------------------------------------------------" >> $@
	@echo ">>> ========= '$(RELDIR)/$*' Program" >> $@
	@echo "---------------------------------------------------------------" >> $@
	@echo >> $@
	@-if test -s Output/$^ ; then \
	  echo "TEST-FAIL" >> $@;\
	else \
	  echo "TEST-PASS" >> $@;\
	fi

Output/%.t1a.bc: Output/%.linked.rbc Output/.dir $(LOPT)
	$(LOPT) -strip-debug-declare -strip-nondebug $< -f -o $@

Output/%.t1b.bc: Output/%.t1a.bc Output/.dir $(LOPT)
	$(LOPT) $(OPT_FLAGS) $< -f -o $@

Output/%.t1c.s: Output/%.t1b.bc Output/.dir $(LLC)
	$(LLC) $(LLC_DEBUG_FLAGS) $< -o $@

Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC)
	grep -v '\.long' < $< \
	  | grep -v '\.byte' \
	  | grep -v '\.short' \
	  | grep -v '\.asci' \
	  | grep -v '\.quad' \
	  | grep -v '\.align' \
	  | grep -v '## DW_AT' \
	  | grep -v '## Abbrev' \
	  | grep -v '## End Of Children' \
	  | grep -v '## Extended Op' \
	  | grep -v 'Ltmp[0-9]' \
	  | grep -v '## DIE' \
	  | grep -v '## $$' \
	  | grep -v '^#.*' \
	  | grep -v '^$$' \
	  | grep -v '__debug_str' \
	  | grep -v 'Lstring' \
	  | grep -v 'Lset' \
	  | grep -v 'debug_loc' \
	  | grep -v 'Lpubtypes' \
	  | grep -v 'Lpubnames' \
	  | grep -v 'Linfo_' \
	  | grep -v 'Lfunc_begin' \
	  | grep -v 'Lfunc_end' \
	  | grep -v 'Ldebug_frame_begin' \
	  | grep -v 'Ldebug_frame_end' > $@

Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT)
	$(LOPT) -strip-nondebug $< -f -o $@

Output/%.t2b.bc: Output/%.t2a.bc Output/.dir $(LOPT)
	$(LOPT) $(OPT_FLAGS) $< -f -o $@

Output/%.t2c.s: Output/%.t2b.bc Output/.dir $(LLC)
	$(LLC) $(LLC_DEBUG_FLAGS) $< -o $@

Output/%.second.s: Output/%.t2c.s Output/.dir
	grep -v '\.long' < $< \
	  | grep -v '\.byte' \
	  | grep -v '\.short' \
	  | grep -v '\.asci' \
	  | grep -v '\.quad' \
	  | grep -v '\.align' \
	  | grep -v '## DW_AT' \
	  | grep -v '## Abbrev' \
	  | grep -v '## End Of Children' \
	  | grep -v '## Extended Op' \
	  | grep -v 'Ltmp[0-9]' \
	  | grep -v '## DIE' \
	  | grep -v '## $$' \
	  | grep -v '^#.*' \
	  | grep -v '^$$' \
	  | grep -v '__debug_str' \
	  | grep -v 'Lstring' \
	  | grep -v 'Lset' \
	  | grep -v 'debug_loc' \
	  | grep -v 'Lpubtypes' \
	  | grep -v 'Lpubnames' \
	  | grep -v 'Linfo_' \
	  | grep -v 'Lfunc_begin' \
	  | grep -v 'Lfunc_end' \
	  | grep -v 'Ldebug_frame_begin' \
	  | grep -v 'Ldebug_frame_end' > $@

Output/%.diff: Output/%.first.s Output/%.second.s
	@-if diff $^ > $@; then \
	 echo "--------- TEST-PASS: $*"; \
	else \
	 echo "--------- TEST-FAIL: $*"; \
	fi

Output/%.report.diff: Output/%.first.s Output/%.second.s
	@diff $^ > $@