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
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple-expr.h"
#include "predict.h"
#include "alloc-pool.h"
#include "tree-pass.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "fold-const.h"
#include "gimple-fold.h"
#include "symbol-summary.h"
#include "tree-vrp.h"
#include "ipa-prop.h"
#include "tree-pretty-print.h"
#include "tree-inline.h"
#include "ipa-fnsummary.h"
#include "ipa-utils.h"
#include "tree-ssa-ccp.h"
#include "stringpool.h"
#include "attribs.h"
#include "gimple-collector.hpp"
static unsigned int iphw_execute();
namespace {
/* ==What is type-escape-analysis?==
* type-escape-analysis is a SIMPLE_IPA_PASS that performs no transformations.
* type-escape-analysis only performs analysis and outputs to a WPA dump file.
*
* ==Why should we run type-escape-analysis?==
* type-escape-analysis is useful to run unit tests in gcc.
* By having the type-escape-analysis execute during WPA we are able to use
* the dejagnu framework to see if an expected output matches the observed
* output in the wpa dump file.
*
* ==How do we use type-escape-analysis?==
* Compile with
* -flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis
*
* To use type-escape-analysis in tests use the following lines
* { dg-do link }
* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" }
* C code to test...
* { dg-final { scan-wpa-ipa-dump "regex" "type-escape-analysis" } }
*
* ==TODO==
* At the moment, the tests are not set up to work with the current framework,
* so I will need to update them in the following day.
*/
const pass_data pass_data_ipa_type_escape_analysis =
{
SIMPLE_IPA_PASS,
"type-escape-analysis",
OPTGROUP_NONE,
TV_NONE,
(PROP_cfg | PROP_ssa),
0,
0,
0,
0,
};
class pass_ipa_type_escape_analysis : public simple_ipa_opt_pass
{
public:
pass_ipa_type_escape_analysis (gcc::context *ctx)
: simple_ipa_opt_pass(pass_data_ipa_type_escape_analysis, ctx)
{}
virtual bool gate(function*) { return flag_ipa_type_escape_analysis; }
virtual unsigned execute (function*) { return iphw_execute(); }
};
} // anon namespace
simple_ipa_opt_pass*
make_pass_ipa_type_escape_analysis (gcc::context *ctx)
{
return new pass_ipa_type_escape_analysis (ctx);
}
static void collect_types();
static unsigned int
iphw_execute()
{
collect_types();
return 0;
}
static void
collect_types()
{
GimpleTypeCollector collector;
collector.walk();
collector.print_collected();
}
|