diff options
author | Kees Cook <keescook@chromium.org> | 2016-12-16 14:36:06 -0500 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2017-01-03 15:08:59 -0500 |
commit | 81d873a87114b05dbb74d1fbf0c4322ba4bfdee4 (patch) | |
tree | 350c48c9aa3921edcea66435b10ec2d6d6799354 /scripts/gcc-plugins | |
parent | 9988f4d577f42f43b7612d755477585f35424af7 (diff) |
gcc-plugins: update gcc-common.h for gcc-7
This updates gcc-common.h from Emese Revfy for gcc 7. This fixes issues seen
by Kugan and Arnd. Build tested with gcc 5.4 and 7 snapshot.
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'scripts/gcc-plugins')
-rw-r--r-- | scripts/gcc-plugins/gcc-common.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h index 950fd2e64bb7..12262c0cc691 100644 --- a/scripts/gcc-plugins/gcc-common.h +++ b/scripts/gcc-plugins/gcc-common.h | |||
@@ -39,6 +39,9 @@ | |||
39 | #include "hash-map.h" | 39 | #include "hash-map.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #if BUILDING_GCC_VERSION >= 7000 | ||
43 | #include "memmodel.h" | ||
44 | #endif | ||
42 | #include "emit-rtl.h" | 45 | #include "emit-rtl.h" |
43 | #include "debug.h" | 46 | #include "debug.h" |
44 | #include "target.h" | 47 | #include "target.h" |
@@ -91,6 +94,9 @@ | |||
91 | #include "tree-ssa-alias.h" | 94 | #include "tree-ssa-alias.h" |
92 | #include "tree-ssa.h" | 95 | #include "tree-ssa.h" |
93 | #include "stringpool.h" | 96 | #include "stringpool.h" |
97 | #if BUILDING_GCC_VERSION >= 7000 | ||
98 | #include "tree-vrp.h" | ||
99 | #endif | ||
94 | #include "tree-ssanames.h" | 100 | #include "tree-ssanames.h" |
95 | #include "print-tree.h" | 101 | #include "print-tree.h" |
96 | #include "tree-eh.h" | 102 | #include "tree-eh.h" |
@@ -287,6 +293,22 @@ static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct c | |||
287 | return NULL; | 293 | return NULL; |
288 | } | 294 | } |
289 | 295 | ||
296 | static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable) | ||
297 | { | ||
298 | cgraph_node_ptr alias; | ||
299 | |||
300 | if (callback(node, data)) | ||
301 | return true; | ||
302 | |||
303 | for (alias = node->same_body; alias; alias = alias->next) { | ||
304 | if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE) | ||
305 | if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable)) | ||
306 | return true; | ||
307 | } | ||
308 | |||
309 | return false; | ||
310 | } | ||
311 | |||
290 | #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ | 312 | #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ |
291 | for ((node) = cgraph_first_function_with_gimple_body(); (node); \ | 313 | for ((node) = cgraph_first_function_with_gimple_body(); (node); \ |
292 | (node) = cgraph_next_function_with_gimple_body(node)) | 314 | (node) = cgraph_next_function_with_gimple_body(node)) |
@@ -399,6 +421,7 @@ typedef union gimple_statement_d gassign; | |||
399 | typedef union gimple_statement_d gcall; | 421 | typedef union gimple_statement_d gcall; |
400 | typedef union gimple_statement_d gcond; | 422 | typedef union gimple_statement_d gcond; |
401 | typedef union gimple_statement_d gdebug; | 423 | typedef union gimple_statement_d gdebug; |
424 | typedef union gimple_statement_d ggoto; | ||
402 | typedef union gimple_statement_d gphi; | 425 | typedef union gimple_statement_d gphi; |
403 | typedef union gimple_statement_d greturn; | 426 | typedef union gimple_statement_d greturn; |
404 | 427 | ||
@@ -452,6 +475,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt) | |||
452 | return stmt; | 475 | return stmt; |
453 | } | 476 | } |
454 | 477 | ||
478 | static inline ggoto *as_a_ggoto(gimple stmt) | ||
479 | { | ||
480 | return stmt; | ||
481 | } | ||
482 | |||
483 | static inline const ggoto *as_a_const_ggoto(const_gimple stmt) | ||
484 | { | ||
485 | return stmt; | ||
486 | } | ||
487 | |||
455 | static inline gphi *as_a_gphi(gimple stmt) | 488 | static inline gphi *as_a_gphi(gimple stmt) |
456 | { | 489 | { |
457 | return stmt; | 490 | return stmt; |
@@ -496,6 +529,14 @@ static inline const greturn *as_a_const_greturn(const_gimple stmt) | |||
496 | 529 | ||
497 | typedef struct rtx_def rtx_insn; | 530 | typedef struct rtx_def rtx_insn; |
498 | 531 | ||
532 | static inline const char *get_decl_section_name(const_tree decl) | ||
533 | { | ||
534 | if (DECL_SECTION_NAME(decl) == NULL_TREE) | ||
535 | return NULL; | ||
536 | |||
537 | return TREE_STRING_POINTER(DECL_SECTION_NAME(decl)); | ||
538 | } | ||
539 | |||
499 | static inline void set_decl_section_name(tree node, const char *value) | 540 | static inline void set_decl_section_name(tree node, const char *value) |
500 | { | 541 | { |
501 | if (value) | 542 | if (value) |
@@ -511,6 +552,7 @@ typedef struct gimple_statement_base gassign; | |||
511 | typedef struct gimple_statement_call gcall; | 552 | typedef struct gimple_statement_call gcall; |
512 | typedef struct gimple_statement_base gcond; | 553 | typedef struct gimple_statement_base gcond; |
513 | typedef struct gimple_statement_base gdebug; | 554 | typedef struct gimple_statement_base gdebug; |
555 | typedef struct gimple_statement_base ggoto; | ||
514 | typedef struct gimple_statement_phi gphi; | 556 | typedef struct gimple_statement_phi gphi; |
515 | typedef struct gimple_statement_base greturn; | 557 | typedef struct gimple_statement_base greturn; |
516 | 558 | ||
@@ -564,6 +606,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt) | |||
564 | return stmt; | 606 | return stmt; |
565 | } | 607 | } |
566 | 608 | ||
609 | static inline ggoto *as_a_ggoto(gimple stmt) | ||
610 | { | ||
611 | return stmt; | ||
612 | } | ||
613 | |||
614 | static inline const ggoto *as_a_const_ggoto(const_gimple stmt) | ||
615 | { | ||
616 | return stmt; | ||
617 | } | ||
618 | |||
567 | static inline gphi *as_a_gphi(gimple stmt) | 619 | static inline gphi *as_a_gphi(gimple stmt) |
568 | { | 620 | { |
569 | return as_a<gphi>(stmt); | 621 | return as_a<gphi>(stmt); |
@@ -611,6 +663,11 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs) | |||
611 | 663 | ||
612 | #define INSN_DELETED_P(insn) (insn)->deleted() | 664 | #define INSN_DELETED_P(insn) (insn)->deleted() |
613 | 665 | ||
666 | static inline const char *get_decl_section_name(const_tree decl) | ||
667 | { | ||
668 | return DECL_SECTION_NAME(decl); | ||
669 | } | ||
670 | |||
614 | /* symtab/cgraph related */ | 671 | /* symtab/cgraph related */ |
615 | #define debug_cgraph_node(node) (node)->debug() | 672 | #define debug_cgraph_node(node) (node)->debug() |
616 | #define cgraph_get_node(decl) cgraph_node::get(decl) | 673 | #define cgraph_get_node(decl) cgraph_node::get(decl) |
@@ -619,6 +676,7 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs) | |||
619 | #define cgraph_n_nodes symtab->cgraph_count | 676 | #define cgraph_n_nodes symtab->cgraph_count |
620 | #define cgraph_max_uid symtab->cgraph_max_uid | 677 | #define cgraph_max_uid symtab->cgraph_max_uid |
621 | #define varpool_get_node(decl) varpool_node::get(decl) | 678 | #define varpool_get_node(decl) varpool_node::get(decl) |
679 | #define dump_varpool_node(file, node) (node)->dump(file) | ||
622 | 680 | ||
623 | #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ | 681 | #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ |
624 | (caller)->create_edge((callee), (call_stmt), (count), (freq)) | 682 | (caller)->create_edge((callee), (call_stmt), (count), (freq)) |
@@ -674,6 +732,11 @@ static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node) | |||
674 | return node->get_alias_target(); | 732 | return node->get_alias_target(); |
675 | } | 733 | } |
676 | 734 | ||
735 | static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable) | ||
736 | { | ||
737 | return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable); | ||
738 | } | ||
739 | |||
677 | static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) | 740 | static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) |
678 | { | 741 | { |
679 | return symtab->add_cgraph_insertion_hook(hook, data); | 742 | return symtab->add_cgraph_insertion_hook(hook, data); |
@@ -731,6 +794,13 @@ static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree l | |||
731 | 794 | ||
732 | template <> | 795 | template <> |
733 | template <> | 796 | template <> |
797 | inline bool is_a_helper<const ggoto *>::test(const_gimple gs) | ||
798 | { | ||
799 | return gs->code == GIMPLE_GOTO; | ||
800 | } | ||
801 | |||
802 | template <> | ||
803 | template <> | ||
734 | inline bool is_a_helper<const greturn *>::test(const_gimple gs) | 804 | inline bool is_a_helper<const greturn *>::test(const_gimple gs) |
735 | { | 805 | { |
736 | return gs->code == GIMPLE_RETURN; | 806 | return gs->code == GIMPLE_RETURN; |
@@ -766,6 +836,16 @@ static inline const gcall *as_a_const_gcall(const_gimple stmt) | |||
766 | return as_a<const gcall *>(stmt); | 836 | return as_a<const gcall *>(stmt); |
767 | } | 837 | } |
768 | 838 | ||
839 | static inline ggoto *as_a_ggoto(gimple stmt) | ||
840 | { | ||
841 | return as_a<ggoto *>(stmt); | ||
842 | } | ||
843 | |||
844 | static inline const ggoto *as_a_const_ggoto(const_gimple stmt) | ||
845 | { | ||
846 | return as_a<const ggoto *>(stmt); | ||
847 | } | ||
848 | |||
769 | static inline gphi *as_a_gphi(gimple stmt) | 849 | static inline gphi *as_a_gphi(gimple stmt) |
770 | { | 850 | { |
771 | return as_a<gphi *>(stmt); | 851 | return as_a<gphi *>(stmt); |
@@ -828,4 +908,9 @@ static inline void debug_gimple_stmt(const_gimple s) | |||
828 | #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) | 908 | #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) |
829 | #endif | 909 | #endif |
830 | 910 | ||
911 | #if BUILDING_GCC_VERSION >= 7000 | ||
912 | #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \ | ||
913 | get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep) | ||
914 | #endif | ||
915 | |||
831 | #endif | 916 | #endif |