+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,
#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.
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 *
{
/* 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);
/* 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);
chkp_versioning (void)
{
struct cgraph_node *node;
+ const char *reason;
bitmap_obstack_initialize (NULL);
&& !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