diff options
author | ienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-16 13:08:24 +0000 |
---|---|---|
committer | ienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-16 13:08:24 +0000 |
commit | 66124ce759998e74294d1e8bfc5bb6277b206170 (patch) | |
tree | b5038b43de84cfd22a1155dcfdf3b9d8bf034b4c | |
parent | 304eacdf4d5d1ae129f6dd284b5e412ee76cfb3b (diff) | |
download | gcc-66124ce759998e74294d1e8bfc5bb6277b206170.tar.gz |
gcc/
PR target/64363
* ipa-chkp.h (chkp_instrumentable_p): New.
* ipa-chkp.c: Include tree-inline.h.
(chkp_instrumentable_p): New.
(chkp_maybe_create_clone): Use chkp_instrumentable_p.
Fix processing of not instrumentable functions.
(chkp_versioning): Use chkp_instrumentable_p. Warn about
not instrumentable functions.
* tree-chkp.c (chkp_add_bounds_to_call_stmt): Use
chkp_instrumentable_p.
* tree-inline.h (copy_forbidden): New.
* tree-inline.c (copy_forbidden): Not static anymore.
gcc/testsuite/
PR target/64363
* gcc.target/i386/chkp-label-address.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219733 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/ipa-chkp.c | 39 | ||||
-rw-r--r-- | gcc/ipa-chkp.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/chkp-label-address.c | 24 | ||||
-rw-r--r-- | gcc/tree-chkp.c | 5 | ||||
-rw-r--r-- | gcc/tree-inline.c | 2 | ||||
-rw-r--r-- | gcc/tree-inline.h | 1 |
8 files changed, 79 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 388c99c0ea2..62871b51c69 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2015-01-16 Ilya Enkovich <ilya.enkovich@intel.com> + + PR target/64363 + * ipa-chkp.h (chkp_instrumentable_p): New. + * ipa-chkp.c: Include tree-inline.h. + (chkp_instrumentable_p): New. + (chkp_maybe_create_clone): Use chkp_instrumentable_p. + Fix processing of not instrumentable functions. + (chkp_versioning): Use chkp_instrumentable_p. Warn about + not instrumentable functions. + * tree-chkp.c (chkp_add_bounds_to_call_stmt): Use + chkp_instrumentable_p. + * tree-inline.h (copy_forbidden): New. + * tree-inline.c (copy_forbidden): Not static anymore. + 2015-01-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * optc-save-gen.awk (cl_target_option_print_diff): Mark indent, diff --git a/gcc/ipa-chkp.c b/gcc/ipa-chkp.c index 30d511d9af9..8e6612ef1ec 100644 --- a/gcc/ipa-chkp.c +++ b/gcc/ipa-chkp.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "lto-streamer.h" #include "cgraph.h" #include "tree-chkp.h" +#include "tree-inline.h" #include "ipa-chkp.h" /* Pointer Bounds Checker has two IPA passes to support code instrumentation. @@ -401,6 +402,18 @@ chkp_maybe_clone_builtin_fndecl (tree fndecl) return clone; } +/* Return 1 if function FNDECL should be instrumented. */ + +bool +chkp_instrumentable_p (tree fndecl) +{ + struct function *fn = DECL_STRUCT_FUNCTION (fndecl); + return (!lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl)) + && (!flag_chkp_instrument_marked_only + || lookup_attribute ("bnd_instrument", DECL_ATTRIBUTES (fndecl))) + && (!fn || !copy_forbidden (fn, fndecl))); +} + /* Return clone created for instrumentation of NODE or NULL. */ cgraph_node * @@ -483,10 +496,10 @@ chkp_maybe_create_clone (tree fndecl) { /* If function will not be instrumented, then it's instrumented version is a thunk for the original. */ - if (lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl)) - || (flag_chkp_instrument_marked_only - && !lookup_attribute ("bnd_instrument", DECL_ATTRIBUTES (fndecl)))) + if (!chkp_instrumentable_p (fndecl)) { + clone->remove_callees (); + clone->remove_all_references (); clone->thunk.thunk_p = true; clone->thunk.add_pointer_bounds_args = true; clone->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE); @@ -532,7 +545,8 @@ chkp_maybe_create_clone (tree fndecl) /* Clone all thunks. */ for (e = node->callers; e; e = e->next_caller) - if (e->caller->thunk.thunk_p) + if (e->caller->thunk.thunk_p + && !e->caller->thunk.add_pointer_bounds_args) { struct cgraph_node *thunk = chkp_maybe_create_clone (e->caller->decl); @@ -578,6 +592,7 @@ static unsigned int chkp_versioning (void) { struct cgraph_node *node; + const char *reason; bitmap_obstack_initialize (NULL); @@ -587,14 +602,20 @@ chkp_versioning (void) && !node->instrumented_version && !node->alias && !node->thunk.thunk_p - && !lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (node->decl)) - && (!flag_chkp_instrument_marked_only - || lookup_attribute ("bnd_instrument", - DECL_ATTRIBUTES (node->decl))) && (!DECL_BUILT_IN (node->decl) || (DECL_BUILT_IN_CLASS (node->decl) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (node->decl) < BEGIN_CHKP_BUILTINS))) - chkp_maybe_create_clone (node->decl); + { + if (chkp_instrumentable_p (node->decl)) + chkp_maybe_create_clone (node->decl); + else if ((reason = copy_forbidden (DECL_STRUCT_FUNCTION (node->decl), + node->decl))) + { + if (warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wchkp, + "function cannot be instrumented")) + inform (DECL_SOURCE_LOCATION (node->decl), reason, node->decl); + } + } } /* Mark all aliases and thunks of functions with no instrumented diff --git a/gcc/ipa-chkp.h b/gcc/ipa-chkp.h index b087227be7d..6708fe9c56a 100644 --- a/gcc/ipa-chkp.h +++ b/gcc/ipa-chkp.h @@ -23,5 +23,6 @@ along with GCC; see the file COPYING3. If not see extern tree chkp_copy_function_type_adding_bounds (tree orig_type); extern tree chkp_maybe_clone_builtin_fndecl (tree fndecl); extern cgraph_node *chkp_maybe_create_clone (tree fndecl); +extern bool chkp_instrumentable_p (tree fndecl); #endif /* GCC_IPA_CHKP_H */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f709fcdb93..6da9eee4d23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-16 Ilya Enkovich <ilya.enkovich@intel.com> + + PR target/64363 + * gcc.target/i386/chkp-label-address.c: New. + 2015-01-16 Janus Weil <janus@gcc.gnu.org> PR fortran/45290 diff --git a/gcc/testsuite/gcc.target/i386/chkp-label-address.c b/gcc/testsuite/gcc.target/i386/chkp-label-address.c new file mode 100644 index 00000000000..05963e2e6ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/chkp-label-address.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx -O2 -Wchkp" } */ + +#include <stdio.h> + +static int f1 () /* { dg-warning "function cannot be instrumented" "" } */ +{ + static int array = &&label_B - &&label_A; + + label_A: + + printf ("%d\n", array); + + label_B: + + return 0; +} + +int f2 (int i) +{ + printf ("%d\n", i); + return f1 (); +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 45ac11e33f5..e7649effd97 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -1686,9 +1686,8 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi) && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_OBJECT_SIZE) return; - /* Do nothing for calls to legacy functions. */ - if (fndecl - && lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl))) + /* Do nothing for calls to not instrumentable functions. */ + if (fndecl && !chkp_instrumentable_p (fndecl)) return; /* Ignore CHKP_INIT_PTR_BOUNDS, CHKP_NULL_PTR_BOUNDS diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 5443ab5bc32..d8abe03e40d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3542,7 +3542,7 @@ has_label_address_in_static_1 (tree *nodep, int *walk_subtrees, void *fnp) /* Determine if the function can be copied. If so return NULL. If not return a string describng the reason for failure. */ -static const char * +const char * copy_forbidden (struct function *fun, tree fndecl) { const char *reason = fun->cannot_be_copied_reason; diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h index 985d83b99eb..f8b2ebfe2dd 100644 --- a/gcc/tree-inline.h +++ b/gcc/tree-inline.h @@ -234,6 +234,7 @@ extern tree remap_type (tree type, copy_body_data *id); extern gimple_seq copy_gimple_seq_and_replace_locals (gimple_seq seq); extern bool debug_find_tree (tree, tree); extern tree copy_fn (tree, tree&, tree&); +extern const char *copy_forbidden (struct function *fun, tree fndecl); /* This is in tree-inline.c since the routine uses data structures from the inliner. */ |