dumper

 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
void dump_func();
static bool is_pointer_var(tree var);
/* IPA passes, compilation of earlier functions or inlining
might have changed some properties, such as marked functions nothrow,
pure, const or noreturn.
Remove redundant edges and basic blocks, and create new ones if necessary.
This pass can't be executed as stand alone pass from pass manager, because
in between inlining and this fixup the verify_flow_info would fail. */
static bool is_pointer_type (tree type)
{
if (POINTER_TYPE_P (type))
return true;
if (TREE_CODE (type) == ARRAY_TYPE)
return is_pointer_var (TREE_TYPE (type));
/* Return true if it is an aggregate type. */
if (AGGREGATE_TYPE_P (type))
return true;
return false;
}
static bool is_pointer_var (tree var)
{
return is_pointer_type (TREE_TYPE (var));
}
void dump_func(){
tree lhsop;
tree rhsop1;
tree rhsop2;
FILE* dump_file;
dump_file = fopen("\/home\/ars\/dump.txt", "w");
fprintf(dump_file, "dump file");
basic_block bb;
int statements_with_pointers = 0;
FOR_EACH_BB (bb) {
gimple_stmt_iterator si;
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) {
gimple stmt;
stmt = gsi_stmt (si);
if (gimple_modified_p (stmt)) {
fprintf(dump_file, "Current gimple statement is modified\n");
}
fprintf(dump_file, "\n current gimple statement code: %d\n", gimple_code(stmt));
switch (gimple_code(stmt)) {
case GIMPLE_ASSIGN:
fprintf(dump_file, " GIMPLE_ASSIGN\n");
//print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
fprintf(dump_file, "Inner representation of assignment:\n");
lhsop = gimple_assign_lhs (stmt);
rhsop1 = gimple_assign_rhs1 (stmt);
rhsop2 = gimple_assign_rhs2 (stmt);
if ((lhsop && is_pointer_var (lhsop)) ||
(rhsop1 && is_pointer_var (rhsop1)) ||
(rhsop2 && is_pointer_var (rhsop2))) {
fprintf(dump_file, "Current statement contains pointers operations.\n");
statements_with_pointers++;
}
fprintf(dump_file, "Here it is: ");
print_gimple_stmt (dump_file, stmt, 0, 0);
//pp_gimple_stmt_1(dump_file, stmt, 0, TDF_RAW);
break;
//case GIMPLE_CALL:
// fprintf(dump_file, " GIMPLE_CALL\n");
// print_gimple_stmt (dump_file, stmt, 0, 0);
// break;
default:
fprintf(dump_file, "\n");
}
//bool flag;
//flag = gimple_has_mem_ops(stmt);
//fprintf(dump_file, "statement has memory operands - %d\n", flag);
//if (flag) fprintf(dump_file, "number of operands for statement - %d\n", gimple_num_ops(stmt));
}
}
fprintf(dump_file, "Number of pointer stmts is %d\n", statements_with_pointers);
fclose(dump_file);
}