blob: 20a71e1a476fca3cf15e9ed545f42f2f08f18609 (
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
|
#include "gimple-escaper.hpp"
void
GimpleEscaper::_init()
{
cgraph_node *cnode = NULL;
FOR_EACH_FUNCTION(cnode)
{
gcc_assert(cnode);
const bool filter = filter_known_function(cnode);
if (filter) continue;
const_tree decl = cnode->decl;
gcc_assert(decl);
undefined.insert(decl);
}
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(cnode)
{
gcc_assert(cnode);
cnode->get_untransformed_body();
const_tree decl = cnode->decl;
gcc_assert(decl);
undefined.erase(decl);
}
}
void
GimpleEscaper::_walk_pre(const_tree t)
{
// Is any global variable escaping?
Reason reason;
exprEscaper.update(expr, reason);
}
void
GimpleEscaper::_walk_pre(gassign *s)
{
Reason reason;
exprEscaper.update(expr, reason);
}
void
GimpleEscaper::_walk_pre(greturn *s)
{
Reason reason;
exprEscaper.update(expr, reason);
}
void
GimpleEscaper::_walk_pre(gcond *s)
{
Reason reason;
exprEscaper.update(expr, reason);
}
void
GimpleEscaper::_walk_pre(gcall *s)
{
tree fn = gimple_call_fndecl(s);
const bool is_undefined = undefined.find(fn) != undefined.end();
Reason arg_reason;
arg_reason.is_escaping = is_undefined;
arg_reason.parameter_is_visible = is_undefined;
unsigned n = gimple_call_num_args(s);
for (unsigned i = 0; i < num_args; i++)
{
const_tree a = gimple_call_arg(s, i);
gcc_assert(a);
exprEscaper.update(a, arg_reason);
}
Reason return_reason;
return_reason.is_escaping = is_undefined;
return_reason.return_is_visible = is_undefined;
const_tree lhs = gimple_call_lhs(s);
if (!lhs) return;
exprEscaper.update(lhs, return_reason);
}
|