Commit af2d2225 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Kees Cook

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: default avatarMasahiro Yamada <masahiroy@kernel.org>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20201202134929.99883-1-masahiroy@kernel.org
parent b6505459
This diff is collapsed.
...@@ -73,18 +73,11 @@ ...@@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0 #define TODO_FLAGS_FINISH 0
#endif #endif
#if BUILDING_GCC_VERSION >= 4009
namespace { namespace {
static const pass_data _PASS_NAME_PASS_DATA = { static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct gimple_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = GIMPLE_PASS, .type = GIMPLE_PASS,
.name = _PASS_NAME_NAME, .name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE, .optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000 #if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009 #elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE, .has_gate = _HAS_GATE,
...@@ -102,12 +95,8 @@ static struct gimple_opt_pass _PASS_NAME_PASS = { ...@@ -102,12 +95,8 @@ static struct gimple_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED, .properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START, .todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH, .todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
}; };
#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public gimple_opt_pass { class _PASS_NAME_PASS : public gimple_opt_pass {
public: public:
_PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {} _PASS_NAME_PASS() : gimple_opt_pass(_PASS_NAME_PASS_DATA, g) {}
...@@ -128,7 +117,6 @@ class _PASS_NAME_PASS : public gimple_opt_pass { ...@@ -128,7 +117,6 @@ class _PASS_NAME_PASS : public gimple_opt_pass {
#else #else
virtual unsigned int execute(void) { return _EXECUTE(); } virtual unsigned int execute(void) { return _EXECUTE(); }
#endif #endif
#endif
}; };
} }
......
...@@ -141,18 +141,11 @@ ...@@ -141,18 +141,11 @@
#define FUNCTION_TRANSFORM_TODO_FLAGS_START 0 #define FUNCTION_TRANSFORM_TODO_FLAGS_START 0
#endif #endif
#if BUILDING_GCC_VERSION >= 4009
namespace { namespace {
static const pass_data _PASS_NAME_PASS_DATA = { static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct ipa_opt_pass_d _PASS_NAME_PASS = {
.pass = {
#endif
.type = IPA_PASS, .type = IPA_PASS,
.name = _PASS_NAME_NAME, .name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE, .optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000 #if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009 #elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE, .has_gate = _HAS_GATE,
...@@ -170,23 +163,8 @@ static struct ipa_opt_pass_d _PASS_NAME_PASS = { ...@@ -170,23 +163,8 @@ static struct ipa_opt_pass_d _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED, .properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START, .todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH, .todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
},
.generate_summary = _GENERATE_SUMMARY,
.write_summary = _WRITE_SUMMARY,
.read_summary = _READ_SUMMARY,
#if BUILDING_GCC_VERSION >= 4006
.write_optimization_summary = _WRITE_OPTIMIZATION_SUMMARY,
.read_optimization_summary = _READ_OPTIMIZATION_SUMMARY,
#endif
.stmt_fixup = _STMT_FIXUP,
.function_transform_todo_flags_start = FUNCTION_TRANSFORM_TODO_FLAGS_START,
.function_transform = _FUNCTION_TRANSFORM,
.variable_transform = _VARIABLE_TRANSFORM,
#endif
}; };
#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public ipa_opt_pass_d { class _PASS_NAME_PASS : public ipa_opt_pass_d {
public: public:
_PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA, _PASS_NAME_PASS() : ipa_opt_pass_d(_PASS_NAME_PASS_DATA,
...@@ -206,7 +184,6 @@ class _PASS_NAME_PASS : public ipa_opt_pass_d { ...@@ -206,7 +184,6 @@ class _PASS_NAME_PASS : public ipa_opt_pass_d {
virtual bool gate(function *) { return _GATE(); } virtual bool gate(function *) { return _GATE(); }
#else #else
virtual bool gate(void) { return _GATE(); } virtual bool gate(void) { return _GATE(); }
#endif
#endif #endif
virtual opt_pass *clone() { return new _PASS_NAME_PASS(); } virtual opt_pass *clone() { return new _PASS_NAME_PASS(); }
......
...@@ -73,18 +73,11 @@ ...@@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0 #define TODO_FLAGS_FINISH 0
#endif #endif
#if BUILDING_GCC_VERSION >= 4009
namespace { namespace {
static const pass_data _PASS_NAME_PASS_DATA = { static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct rtl_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = RTL_PASS, .type = RTL_PASS,
.name = _PASS_NAME_NAME, .name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE, .optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000 #if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009 #elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE, .has_gate = _HAS_GATE,
...@@ -102,12 +95,8 @@ static struct rtl_opt_pass _PASS_NAME_PASS = { ...@@ -102,12 +95,8 @@ static struct rtl_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED, .properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START, .todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH, .todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
}; };
#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public rtl_opt_pass { class _PASS_NAME_PASS : public rtl_opt_pass {
public: public:
_PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {} _PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {}
...@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void) ...@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
{ {
return new _PASS_NAME_PASS(); return new _PASS_NAME_PASS();
} }
#else
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return &_PASS_NAME_PASS.pass;
}
#endif
/* clean up user provided defines */ /* clean up user provided defines */
#undef PASS_NAME #undef PASS_NAME
......
...@@ -73,18 +73,11 @@ ...@@ -73,18 +73,11 @@
#define TODO_FLAGS_FINISH 0 #define TODO_FLAGS_FINISH 0
#endif #endif
#if BUILDING_GCC_VERSION >= 4009
namespace { namespace {
static const pass_data _PASS_NAME_PASS_DATA = { static const pass_data _PASS_NAME_PASS_DATA = {
#else
static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
.pass = {
#endif
.type = SIMPLE_IPA_PASS, .type = SIMPLE_IPA_PASS,
.name = _PASS_NAME_NAME, .name = _PASS_NAME_NAME,
#if BUILDING_GCC_VERSION >= 4008
.optinfo_flags = OPTGROUP_NONE, .optinfo_flags = OPTGROUP_NONE,
#endif
#if BUILDING_GCC_VERSION >= 5000 #if BUILDING_GCC_VERSION >= 5000
#elif BUILDING_GCC_VERSION == 4009 #elif BUILDING_GCC_VERSION == 4009
.has_gate = _HAS_GATE, .has_gate = _HAS_GATE,
...@@ -102,12 +95,8 @@ static struct simple_ipa_opt_pass _PASS_NAME_PASS = { ...@@ -102,12 +95,8 @@ static struct simple_ipa_opt_pass _PASS_NAME_PASS = {
.properties_destroyed = PROPERTIES_DESTROYED, .properties_destroyed = PROPERTIES_DESTROYED,
.todo_flags_start = TODO_FLAGS_START, .todo_flags_start = TODO_FLAGS_START,
.todo_flags_finish = TODO_FLAGS_FINISH, .todo_flags_finish = TODO_FLAGS_FINISH,
#if BUILDING_GCC_VERSION < 4009
}
#endif
}; };
#if BUILDING_GCC_VERSION >= 4009
class _PASS_NAME_PASS : public simple_ipa_opt_pass { class _PASS_NAME_PASS : public simple_ipa_opt_pass {
public: public:
_PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {} _PASS_NAME_PASS() : simple_ipa_opt_pass(_PASS_NAME_PASS_DATA, g) {}
...@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void) ...@@ -136,12 +125,6 @@ opt_pass *_MAKE_PASS_NAME_PASS(void)
{ {
return new _PASS_NAME_PASS(); return new _PASS_NAME_PASS();
} }
#else
struct opt_pass *_MAKE_PASS_NAME_PASS(void)
{
return &_PASS_NAME_PASS.pass;
}
#endif
/* clean up user provided defines */ /* clean up user provided defines */
#undef PASS_NAME #undef PASS_NAME
......
...@@ -125,11 +125,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name, ...@@ -125,11 +125,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
bool *no_add_attrs) bool *no_add_attrs)
{ {
tree type; tree type;
#if BUILDING_GCC_VERSION <= 4007
VEC(constructor_elt, gc) *vals;
#else
vec<constructor_elt, va_gc> *vals; vec<constructor_elt, va_gc> *vals;
#endif
switch (TREE_CODE(*node)) { switch (TREE_CODE(*node)) {
default: default:
...@@ -181,11 +177,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name, ...@@ -181,11 +177,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
if (fld) if (fld)
break; break;
#if BUILDING_GCC_VERSION <= 4007
vals = VEC_alloc(constructor_elt, gc, nelt);
#else
vec_alloc(vals, nelt); vec_alloc(vals, nelt);
#endif
for (fld = lst; fld; fld = TREE_CHAIN(fld)) { for (fld = lst; fld; fld = TREE_CHAIN(fld)) {
tree random_const, fld_t = TREE_TYPE(fld); tree random_const, fld_t = TREE_TYPE(fld);
...@@ -225,11 +217,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name, ...@@ -225,11 +217,7 @@ static tree handle_latent_entropy_attribute(tree *node, tree name,
elt_size_int = TREE_INT_CST_LOW(elt_size); elt_size_int = TREE_INT_CST_LOW(elt_size);
nelt = array_size_int / elt_size_int; nelt = array_size_int / elt_size_int;
#if BUILDING_GCC_VERSION <= 4007
vals = VEC_alloc(constructor_elt, gc, nelt);
#else
vec_alloc(vals, nelt); vec_alloc(vals, nelt);
#endif
for (i = 0; i < nelt; i++) { for (i = 0; i < nelt; i++) {
tree cst = size_int(i); tree cst = size_int(i);
......
...@@ -590,16 +590,12 @@ static void register_attributes(void *event_data, void *data) ...@@ -590,16 +590,12 @@ static void register_attributes(void *event_data, void *data)
randomize_layout_attr.name = "randomize_layout"; randomize_layout_attr.name = "randomize_layout";
randomize_layout_attr.type_required = true; randomize_layout_attr.type_required = true;
randomize_layout_attr.handler = handle_randomize_layout_attr; randomize_layout_attr.handler = handle_randomize_layout_attr;
#if BUILDING_GCC_VERSION >= 4007
randomize_layout_attr.affects_type_identity = true; randomize_layout_attr.affects_type_identity = true;
#endif
no_randomize_layout_attr.name = "no_randomize_layout"; no_randomize_layout_attr.name = "no_randomize_layout";
no_randomize_layout_attr.type_required = true; no_randomize_layout_attr.type_required = true;
no_randomize_layout_attr.handler = handle_randomize_layout_attr; no_randomize_layout_attr.handler = handle_randomize_layout_attr;
#if BUILDING_GCC_VERSION >= 4007
no_randomize_layout_attr.affects_type_identity = true; no_randomize_layout_attr.affects_type_identity = true;
#endif
randomize_considered_attr.name = "randomize_considered"; randomize_considered_attr.name = "randomize_considered";
randomize_considered_attr.type_required = true; randomize_considered_attr.type_required = true;
......
...@@ -80,10 +80,8 @@ static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data) ...@@ -80,10 +80,8 @@ static void sancov_start_unit(void __unused *gcc_data, void __unused *user_data)
nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL); nothrow_attr = tree_cons(get_identifier("nothrow"), NULL, NULL);
decl_attributes(&sancov_fndecl, nothrow_attr, 0); decl_attributes(&sancov_fndecl, nothrow_attr, 0);
gcc_assert(TREE_NOTHROW(sancov_fndecl)); gcc_assert(TREE_NOTHROW(sancov_fndecl));
#if BUILDING_GCC_VERSION > 4005
leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL); leaf_attr = tree_cons(get_identifier("leaf"), NULL, NULL);
decl_attributes(&sancov_fndecl, leaf_attr, 0); decl_attributes(&sancov_fndecl, leaf_attr, 0);
#endif
} }
__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) __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 ...@@ -106,11 +104,7 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gc
}; };
/* BBs can be split afterwards?? */ /* BBs can be split afterwards?? */
#if BUILDING_GCC_VERSION >= 4009
PASS_INFO(sancov, "asan", 0, PASS_POS_INSERT_BEFORE); PASS_INFO(sancov, "asan", 0, PASS_POS_INSERT_BEFORE);
#else
PASS_INFO(sancov, "nrv", 1, PASS_POS_INSERT_BEFORE);
#endif
if (!plugin_default_version_check(version, &gcc_version)) { if (!plugin_default_version_check(version, &gcc_version)) {
error(G_("incompatible gcc/plugin versions")); error(G_("incompatible gcc/plugin versions"));
......
...@@ -80,10 +80,8 @@ static bool is_alloca(gimple stmt) ...@@ -80,10 +80,8 @@ static bool is_alloca(gimple stmt)
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA)) if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
return true; return true;
#if BUILDING_GCC_VERSION >= 4007
if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN)) if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
return true; return true;
#endif
return false; return false;
} }
...@@ -322,7 +320,7 @@ static void remove_stack_tracking_gcall(void) ...@@ -322,7 +320,7 @@ static void remove_stack_tracking_gcall(void)
/* Delete the stackleak_track_stack() call */ /* Delete the stackleak_track_stack() call */
delete_insn_and_edges(insn); delete_insn_and_edges(insn);
#if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION < 8000 #if BUILDING_GCC_VERSION < 8000
if (GET_CODE(next) == NOTE && if (GET_CODE(next) == NOTE &&
NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) { NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
insn = next; insn = next;
......
...@@ -68,9 +68,7 @@ static void register_attributes(void *event_data, void *data) ...@@ -68,9 +68,7 @@ static void register_attributes(void *event_data, void *data)
{ {
user_attr.name = "user"; user_attr.name = "user";
user_attr.handler = handle_user_attribute; user_attr.handler = handle_user_attribute;
#if BUILDING_GCC_VERSION >= 4007
user_attr.affects_type_identity = true; user_attr.affects_type_identity = true;
#endif
register_attribute(&user_attr); register_attribute(&user_attr);
} }
...@@ -137,11 +135,9 @@ static void initialize(tree var) ...@@ -137,11 +135,9 @@ static void initialize(tree var)
if (!gimple_assign_single_p(stmt)) if (!gimple_assign_single_p(stmt))
continue; continue;
rhs1 = gimple_assign_rhs1(stmt); rhs1 = gimple_assign_rhs1(stmt);
#if BUILDING_GCC_VERSION >= 4007
/* ... of a non-clobbering expression... */ /* ... of a non-clobbering expression... */
if (TREE_CLOBBER_P(rhs1)) if (TREE_CLOBBER_P(rhs1))
continue; continue;
#endif
/* ... to our variable... */ /* ... to our variable... */
if (gimple_get_lhs(stmt) != var) if (gimple_get_lhs(stmt) != var)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment