Skip to content

Commit af2d222

Browse files
masahir0ykees
authored andcommitted
gcc-plugins: remove code for GCC versions older than 4.9
Documentation/process/changes.rst says the minimal GCC version is 4.9. Hence, BUILDING_GCC_VERSION is greater than or equal to 4009. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b650545 commit af2d222

10 files changed

+1
-505
lines changed

scripts/gcc-plugins/gcc-common.h

Lines changed: 0 additions & 407 deletions
Large diffs are not rendered by default.

scripts/gcc-plugins/gcc-generate-gimple-pass.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,11 @@
7373
#define TODO_FLAGS_FINISH 0
7474
#endif
7575

76-
#if BUILDING_GCC_VERSION >= 4009
7776
namespace {
7877
static const pass_data _PASS_NAME_PASS_DATA = {
79-
#else
80-
static struct gimple_opt_pass _PASS_NAME_PASS = {
81-
.pass = {
82-
#endif
8378
.type = GIMPLE_PASS,
8479
.name = _PASS_NAME_NAME,
85-
#if BUILDING_GCC_VERSION >= 4008
8680
.optinfo_flags = OPTGROUP_NONE,
87-
#endif
8881
#if BUILDING_GCC_VERSION >= 5000
8982
#elif BUILDING_GCC_VERSION == 4009
9083
.has_gate = _HAS_GATE,
@@ -102,12 +95,8 @@ static struct gimple_opt_pass _PASS_NAME_PASS = {
10295
.properties_destroyed = PROPERTIES_DESTROYED,
10396
.todo_flags_start = TODO_FLAGS_START,
10497
.todo_flags_finish = TODO_FLAGS_FINISH,
105-
#if BUILDING_GCC_VERSION < 4009
106-
}
107-
#endif
10898
};
10999

110-
#if BUILDING_GCC_VERSION >= 4009
111100
class _PASS_NAME_PASS : public gimple_opt_pass {
112101
public:
113102
_PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {}
@@ -128,7 +117,6 @@ class _PASS_NAME_PASS : public gimple_opt_pass {
128117
#else
129118
virtual unsigned int execute(void) { return _EXECUTE(); }
130119
#endif
131-
#endif
132120
};
133121
}
134122

scripts/gcc-plugins/gcc-generate-ipa-pass.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,11 @@
141141
#define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
142142
#endif
143143

144-
#if BUILDING_GCC_VERSION >= 4009
145144
namespace {
146145
static const pass_data _PASS_NAME_PASS_DATA = {
147-
#else
148-
static struct ipa_opt_pass_d _PASS_NAME_PASS = {
149-
.pass = {
150-
#endif
151146
.type = IPA_PASS,
152147
.name = _PASS_NAME_NAME,
153-
#if BUILDING_GCC_VERSION >= 4008
154148
.optinfo_flags = OPTGROUP_NONE,
155-
#endif
156149
#if BUILDING_GCC_VERSION >= 5000
157150
#elif BUILDING_GCC_VERSION == 4009
158151
.has_gate = _HAS_GATE,
@@ -170,23 +163,8 @@ static struct ipa_opt_pass_d _PASS_NAME_PASS = {
170163
.properties_destroyed = PROPERTIES_DESTROYED,
171164
.todo_flags_start = TODO_FLAGS_START,
172165
.todo_flags_finish = TODO_FLAGS_FINISH,
173-
#if BUILDING_GCC_VERSION < 4009
174-
},
175-
.generate_summary = _GENERATE_SUMMARY,
176-
.write_summary = _WRITE_SUMMARY,
177-
.read_summary = _READ_SUMMARY,
178-
#if BUILDING_GCC_VERSION >= 4006
179-
.write_optimization_summary = _WRITE_OPTIMIZATION_SUMMARY,
180-
.read_optimization_summary = _READ_OPTIMIZATION_SUMMARY,
181-
#endif
182-
.stmt_fixup = _STMT_FIXUP,
183-
.function_transform_todo_flags_start = FUNCTION_TRANSFORM_TODO_FLAGS_START,
184-
.function_transform = _FUNCTION_TRANSFORM,
185-
.variable_transform = _VARIABLE_TRANSFORM,
186-
#endif
187166
};
188167

189-
#if BUILDING_GCC_VERSION >= 4009
190168
class _PASS_NAME_PASS : public ipa_opt_pass_d {
191169
public:
192170
_PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA,
@@ -206,7 +184,6 @@ class _PASS_NAME_PASS : public ipa_opt_pass_d {
206184
virtual bool gate(function *) { return _GATE(); }
207185
#else
208186
virtual bool gate(void) { return _GATE(); }
209-
#endif
210187
#endif
211188

212189
virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }

scripts/gcc-plugins/gcc-generate-rtl-pass.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,11 @@
7373
#define TODO_FLAGS_FINISH 0
7474
#endif
7575

76-
#if BUILDING_GCC_VERSION >= 4009
7776
namespace {
7877
static const pass_data _PASS_NAME_PASS_DATA = {
79-
#else
80-
static struct rtl_opt_pass _PASS_NAME_PASS = {
81-
.pass = {
82-
#endif
8378
.type = RTL_PASS,
8479
.name = _PASS_NAME_NAME,
85-
#if BUILDING_GCC_VERSION >= 4008
8680
.optinfo_flags = OPTGROUP_NONE,
87-
#endif
8881
#if BUILDING_GCC_VERSION >= 5000
8982
#elif BUILDING_GCC_VERSION == 4009
9083
.has_gate = _HAS_GATE,
@@ -102,12 +95,8 @@ static struct rtl_opt_pass _PASS_NAME_PASS = {
10295
.properties_destroyed = PROPERTIES_DESTROYED,
10396
.todo_flags_start = TODO_FLAGS_START,
10497
.todo_flags_finish = TODO_FLAGS_FINISH,
105-
#if BUILDING_GCC_VERSION < 4009
106-
}
107-
#endif
10898
};
10999

110-
#if BUILDING_GCC_VERSION >= 4009
111100
class _PASS_NAME_PASS : public rtl_opt_pass {
112101
public:
113102
_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}
@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
136125
{
137126
return new _PASS_NAME_PASS();
138127
}
139-
#else
140-
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
141-
{
142-
return &_PASS_NAME_PASS.pass;
143-
}
144-
#endif
145128

146129
/* clean up user provided defines */
147130
#undef PASS_NAME

scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,11 @@
7373
#define TODO_FLAGS_FINISH 0
7474
#endif
7575

76-
#if BUILDING_GCC_VERSION >= 4009
7776
namespace {
7877
static const pass_data _PASS_NAME_PASS_DATA = {
79-
#else
80-
static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
81-
.pass = {
82-
#endif
8378
.type = SIMPLE_IPA_PASS,
8479
.name = _PASS_NAME_NAME,
85-
#if BUILDING_GCC_VERSION >= 4008
8680
.optinfo_flags = OPTGROUP_NONE,
87-
#endif
8881
#if BUILDING_GCC_VERSION >= 5000
8982
#elif BUILDING_GCC_VERSION == 4009
9083
.has_gate = _HAS_GATE,
@@ -102,12 +95,8 @@ static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
10295
.properties_destroyed = PROPERTIES_DESTROYED,
10396
.todo_flags_start = TODO_FLAGS_START,
10497
.todo_flags_finish = TODO_FLAGS_FINISH,
105-
#if BUILDING_GCC_VERSION < 4009
106-
}
107-
#endif
10898
};
10999

110-
#if BUILDING_GCC_VERSION >= 4009
111100
class _PASS_NAME_PASS : public simple_ipa_opt_pass {
112101
public:
113102
_PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {}
@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
136125
{
137126
return new _PASS_NAME_PASS();
138127
}
139-
#else
140-
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
141-
{
142-
return &_PASS_NAME_PASS.pass;
143-
}
144-
#endif
145128

146129
/* clean up user provided defines */
147130
#undef PASS_NAME

scripts/gcc-plugins/latent_entropy_plugin.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
125125
bool *no_add_attrs)
126126
{
127127
tree type;
128-
#if BUILDING_GCC_VERSION <= 4007
129-
VEC(constructor_elt, gc) *vals;
130-
#else
131128
vec<constructor_elt, va_gc> *vals;
132-
#endif
133129

134130
switch (TREE_CODE(*node)) {
135131
default:
@@ -181,11 +177,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
181177
if (fld)
182178
break;
183179

184-
#if BUILDING_GCC_VERSION <= 4007
185-
vals = VEC_alloc(constructor_elt, gc, nelt);
186-
#else
187180
vec_alloc(vals, nelt);
188-
#endif
189181

190182
for (fld = lst; fld; fld = TREE_CHAIN(fld)) {
191183
tree random_const, fld_t = TREE_TYPE(fld);
@@ -225,11 +217,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
225217
elt_size_int = TREE_INT_CST_LOW(elt_size);
226218
nelt = array_size_int / elt_size_int;
227219

228-
#if BUILDING_GCC_VERSION <= 4007
229-
vals = VEC_alloc(constructor_elt, gc, nelt);
230-
#else
231220
vec_alloc(vals, nelt);
232-
#endif
233221

234222
for (i = 0; i < nelt; i++) {
235223
tree cst = size_int(i);

scripts/gcc-plugins/randomize_layout_plugin.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,12 @@ static void register_attributes(void *event_data, void *data)
590590
randomize_layout_attr.name = "randomize_layout";
591591
randomize_layout_attr.type_required = true;
592592
randomize_layout_attr.handler = handle_randomize_layout_attr;
593-
#if BUILDING_GCC_VERSION >= 4007
594593
randomize_layout_attr.affects_type_identity = true;
595-
#endif
596594

597595
no_randomize_layout_attr.name = "no_randomize_layout";
598596
no_randomize_layout_attr.type_required = true;
599597
no_randomize_layout_attr.handler = handle_randomize_layout_attr;
600-
#if BUILDING_GCC_VERSION >= 4007
601598
no_randomize_layout_attr.affects_type_identity = true;
602-
#endif
603599

604600
randomize_considered_attr.name = "randomize_considered";
605601
randomize_considered_attr.type_required = true;

scripts/gcc-plugins/sancov_plugin.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data)
8080
nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL);
8181
decl_attributes(&sancov_fndecl, nothrow_attr, 0);
8282
gcc_assert(TREE_NOTHROW(sancov_fndecl));
83-
#if BUILDING_GCC_VERSION > 4005
8483
leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL);
8584
decl_attributes(&sancov_fndecl, leaf_attr, 0);
86-
#endif
8785
}
8886

8987
__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
@@ -106,11 +104,7 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc
106104
};
107105

108106
/* BBs can be split afterwards?? */
109-
#if BUILDING_GCC_VERSION >= 4009
110107
PASS_INFO(sancov, "asan", 0, PASS_POS_INSERT_BEFORE);
111-
#else
112-
PASS_INFO(sancov, "nrv", 1, PASS_POS_INSERT_BEFORE);
113-
#endif
114108

115109
if (!plugin_default_version_check(version, &gcc_version)) {
116110
error(G_("incompatible gcc/plugin versions"));

scripts/gcc-plugins/stackleak_plugin.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ static bool is_alloca(gimple stmt)
8080
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
8181
return true;
8282

83-
#if BUILDING_GCC_VERSION >= 4007
8483
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
8584
return true;
86-
#endif
8785

8886
return false;
8987
}
@@ -322,7 +320,7 @@ static void remove_stack_tracking_gcall(void)
322320

323321
/* Delete the stackleak_track_stack() call */
324322
delete_insn_and_edges(insn);
325-
#if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION < 8000
323+
#if BUILDING_GCC_VERSION < 8000
326324
if (GET_CODE(next) == NOTE &&
327325
NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
328326
insn = next;

scripts/gcc-plugins/structleak_plugin.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ static void register_attributes(void *event_data, void *data)
6868
{
6969
user_attr.name = "user";
7070
user_attr.handler = handle_user_attribute;
71-
#if BUILDING_GCC_VERSION >= 4007
7271
user_attr.affects_type_identity = true;
73-
#endif
7472

7573
register_attribute(&user_attr);
7674
}
@@ -137,11 +135,9 @@ static void initialize(tree var)
137135
if (!gimple_assign_single_p(stmt))
138136
continue;
139137
rhs1 = gimple_assign_rhs1(stmt);
140-
#if BUILDING_GCC_VERSION >= 4007
141138
/* ... of a non-clobbering expression... */
142139
if (TREE_CLOBBER_P(rhs1))
143140
continue;
144-
#endif
145141
/* ... to our variable... */
146142
if (gimple_get_lhs(stmt) != var)
147143
continue;

0 commit comments

Comments
 (0)