Print this page
11972 resync smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/test-unssa.c
+++ new/usr/src/tools/smatch/src/test-unssa.c
1 1 #include <stdio.h>
2 2 #include <assert.h>
3 3
4 4 #include "symbol.h"
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
5 5 #include "expression.h"
6 6 #include "linearize.h"
7 7 #include "flow.h"
8 8
9 9
10 10 static void output_bb(struct basic_block *bb, unsigned long generation)
11 11 {
12 12 struct instruction *insn;
13 13
14 14 bb->generation = generation;
15 - printf(".L%u\n", bb->nr);
15 + printf("%s\n", show_label(bb));
16 16
17 17 FOR_EACH_PTR(bb->insns, insn) {
18 18 if (!insn->bb)
19 19 continue;
20 20 printf("\t%s\n", show_instruction(insn));
21 21 }
22 22 END_FOR_EACH_PTR(insn);
23 23
24 24 printf("\n");
25 25 }
26 26
27 27 static void output_fn(struct entrypoint *ep)
28 28 {
29 29 struct basic_block *bb;
30 30 unsigned long generation = ++bb_generation;
31 31 struct symbol *sym = ep->name;
32 32 const char *name = show_ident(sym->ident);
33 33
34 34 if (sym->ctype.modifiers & MOD_STATIC)
35 35 printf("\n\n%s:\n", name);
36 36 else
37 37 printf("\n\n.globl %s\n%s:\n", name, name);
38 38
39 39 unssa(ep);
40 40
41 41 FOR_EACH_PTR(ep->bbs, bb) {
42 42 if (bb->generation == generation)
43 43 continue;
44 44 output_bb(bb, generation);
45 45 }
46 46 END_FOR_EACH_PTR(bb);
47 47 }
48 48
49 49 static int output_data(struct symbol *sym)
50 50 {
51 51 printf("symbol %s:\n", show_ident(sym->ident));
52 52 printf("\ttype = %d\n", sym->ctype.base_type->type);
53 53 printf("\tmodif= %lx\n", sym->ctype.modifiers);
54 54
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
55 55 return 0;
56 56 }
57 57
58 58 static int compile(struct symbol_list *list)
59 59 {
60 60 struct symbol *sym;
61 61 FOR_EACH_PTR(list, sym) {
62 62 struct entrypoint *ep;
63 63 expand_symbol(sym);
64 64 ep = linearize_symbol(sym);
65 + if (!(fdump_ir & PASS_FINAL))
66 + continue;
65 67 if (ep)
66 68 output_fn(ep);
67 69 else
68 70 output_data(sym);
69 71 }
70 72 END_FOR_EACH_PTR(sym);
71 73
72 74 return 0;
73 75 }
74 76
75 77 int main(int argc, char **argv)
76 78 {
77 79 struct string_list * filelist = NULL;
78 80 char *file;
79 81
80 82 compile(sparse_initialize(argc, argv, &filelist));
81 - FOR_EACH_PTR_NOTAG(filelist, file) {
83 + FOR_EACH_PTR(filelist, file) {
82 84 compile(sparse(file));
83 - } END_FOR_EACH_PTR_NOTAG(file);
85 + } END_FOR_EACH_PTR(file);
84 86
85 87 report_stats();
86 88 return 0;
87 89 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX