Daily bump.
[official-gcc.git] / gcc / ipa-chkp.c
blob46b2139758aaf2e918bfe73b484856a942f49c2c
1 /* Pointer Bounds Checker IPA passes.
2 Copyright (C) 2014 Free Software Foundation, Inc.
3 Contributed by Ilya Enkovich (ilya.enkovich@intel.com)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree-core.h"
25 #include "stor-layout.h"
26 #include "tree.h"
27 #include "tree-pass.h"
28 #include "stringpool.h"
29 #include "bitmap.h"
30 #include "gimple-expr.h"
31 #include "tm.h"
32 #include "hard-reg-set.h"
33 #include "function.h"
34 #include "is-a.h"
35 #include "tree-ssa-alias.h"
36 #include "predict.h"
37 #include "basic-block.h"
38 #include "gimple.h"
39 #include "ipa-ref.h"
40 #include "lto-streamer.h"
41 #include "cgraph.h"
42 #include "tree-chkp.h"
43 #include "ipa-chkp.h"
45 /* Pointer Bounds Checker has two IPA passes to support code instrumentation.
47 In instrumented code each pointer is provided with bounds. For input
48 pointer parameters it means we also have bounds passed. For calls it
49 means we have additional bounds arguments for pointer arguments.
51 To have all IPA optimizations working correctly we have to express
52 dataflow between passed and received bounds explicitly via additional
53 entries in function declaration arguments list and in function type.
54 Since we may have both instrumented and not instrumented code at the
55 same time, we cannot replace all original functions with their
56 instrumented variants. Therefore we create clones (versions) instead.
58 Instrumentation clones creation is a separate IPA pass which is a part
59 of early local passes. Clones are created after SSA is built (because
60 instrumentation pass works on SSA) and before any transformations
61 which may change pointer flow and therefore lead to incorrect code
62 instrumentation (possibly causing false bounds check failures).
64 Instrumentation clones have pointer bounds arguments added right after
65 pointer arguments. Clones have assembler name of the original
66 function with suffix added. New assembler name is in transparent
67 alias chain with the original name. Thus we expect all calls to the
68 original and instrumented functions look similar in assembler.
70 During instrumentation versioning pass we create instrumented versions
71 of all function with body and also for all their aliases and thunks.
72 Clones for functions with no body are created on demand (usually
73 during call instrumentation).
75 Original and instrumented function nodes are connected with IPA
76 reference IPA_REF_CHKP. It is mostly done to have reachability
77 analysis working correctly. We may have no references to the
78 instrumented function in the code but it still should be counted
79 as reachable if the original function is reachable.
81 When original function bodies are not needed anymore we release
82 them and transform functions into a special kind of thunks. Each
83 thunk has a call edge to the instrumented version. These thunks
84 help to keep externally visible instrumented functions visible
85 when linker resolution files are used. Linker has no info about
86 connection between original and instrumented function and
87 therefore we may wrongly decide (due to difference in assembler
88 names) that instrumented function version is local and can be
89 removed. */
91 #define CHKP_BOUNDS_OF_SYMBOL_PREFIX "__chkp_bounds_of_"
93 /* Build a clone of FNDECL with a modified name. */
95 static tree
96 chkp_build_instrumented_fndecl (tree fndecl)
98 tree new_decl = copy_node (fndecl);
99 tree new_name;
100 std::string s;
102 /* called_as_built_in checks DECL_NAME to identify calls to
103 builtins. We want instrumented calls to builtins to be
104 recognized by called_as_built_in. Therefore use original
105 DECL_NAME for cloning with no prefixes. */
106 s = IDENTIFIER_POINTER (DECL_NAME (fndecl));
107 s += ".chkp";
108 DECL_NAME (new_decl) = get_identifier (s.c_str ());
110 /* References to the original and to the instrumented version
111 should look the same in the output assembly. And we cannot
112 use the same assembler name for the instrumented version
113 because it conflicts with decl merging algorithms in LTO.
114 Achieve the result by using transparent alias name for the
115 instrumented version. */
116 s = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
117 s += ".chkp";
118 new_name = get_identifier (s.c_str ());
119 IDENTIFIER_TRANSPARENT_ALIAS (new_name) = 1;
120 TREE_CHAIN (new_name) = DECL_ASSEMBLER_NAME (fndecl);
121 SET_DECL_ASSEMBLER_NAME (new_decl, new_name);
123 /* For functions with body versioning will make a copy of arguments.
124 For functions with no body we need to do it here. */
125 if (!gimple_has_body_p (fndecl))
126 DECL_ARGUMENTS (new_decl) = copy_list (DECL_ARGUMENTS (fndecl));
128 /* We are going to modify attributes list and therefore should
129 make own copy. */
130 DECL_ATTRIBUTES (new_decl) = copy_list (DECL_ATTRIBUTES (fndecl));
132 /* Change builtin function code. */
133 if (DECL_BUILT_IN (new_decl))
135 gcc_assert (DECL_BUILT_IN_CLASS (new_decl) == BUILT_IN_NORMAL);
136 gcc_assert (DECL_FUNCTION_CODE (new_decl) < BEGIN_CHKP_BUILTINS);
137 DECL_FUNCTION_CODE (new_decl)
138 = (enum built_in_function)(DECL_FUNCTION_CODE (new_decl)
139 + BEGIN_CHKP_BUILTINS + 1);
142 return new_decl;
146 /* Fix operands of attribute from ATTRS list named ATTR_NAME.
147 Integer operands are replaced with values according to
148 INDEXES map having LEN elements. For operands out of len
149 we just add DELTA. */
151 static void
152 chkp_map_attr_arg_indexes (tree attrs, const char *attr_name,
153 unsigned *indexes, int len, int delta)
155 tree attr = lookup_attribute (attr_name, attrs);
156 tree op;
158 if (!attr)
159 return;
161 TREE_VALUE (attr) = copy_list (TREE_VALUE (attr));
162 for (op = TREE_VALUE (attr); op; op = TREE_CHAIN (op))
164 int idx;
166 if (TREE_CODE (TREE_VALUE (op)) != INTEGER_CST)
167 continue;
169 idx = TREE_INT_CST_LOW (TREE_VALUE (op));
171 /* If idx exceeds indexes length then we just
172 keep it at the same distance from the last
173 known arg. */
174 if (idx > len)
175 idx += delta;
176 else
177 idx = indexes[idx - 1] + 1;
178 TREE_VALUE (op) = build_int_cst (TREE_TYPE (TREE_VALUE (op)), idx);
182 /* Make a copy of function type ORIG_TYPE adding pointer
183 bounds as additional arguments. */
185 tree
186 chkp_copy_function_type_adding_bounds (tree orig_type)
188 tree type;
189 tree arg_type, attrs, t;
190 unsigned len = list_length (TYPE_ARG_TYPES (orig_type));
191 unsigned *indexes = XALLOCAVEC (unsigned, len);
192 unsigned idx = 0, new_idx = 0;
194 for (arg_type = TYPE_ARG_TYPES (orig_type);
195 arg_type;
196 arg_type = TREE_CHAIN (arg_type))
197 if (TREE_VALUE (arg_type) == void_type_node)
198 continue;
199 else if (BOUNDED_TYPE_P (TREE_VALUE (arg_type))
200 || pass_by_reference (NULL, TYPE_MODE (TREE_VALUE (arg_type)),
201 TREE_VALUE (arg_type), true)
202 || chkp_type_has_pointer (TREE_VALUE (arg_type)))
203 break;
205 /* We may use original type if there are no bounds passed. */
206 if (!arg_type)
207 return orig_type;
209 type = copy_node (orig_type);
210 TYPE_ARG_TYPES (type) = copy_list (TYPE_ARG_TYPES (type));
212 for (arg_type = TYPE_ARG_TYPES (type);
213 arg_type;
214 arg_type = TREE_CHAIN (arg_type))
216 indexes[idx++] = new_idx++;
218 /* pass_by_reference returns 1 for void type,
219 so check for it first. */
220 if (TREE_VALUE (arg_type) == void_type_node)
221 continue;
222 else if (BOUNDED_TYPE_P (TREE_VALUE (arg_type))
223 || pass_by_reference (NULL, TYPE_MODE (TREE_VALUE (arg_type)),
224 TREE_VALUE (arg_type), true))
226 tree new_type = build_tree_list (NULL_TREE,
227 pointer_bounds_type_node);
228 TREE_CHAIN (new_type) = TREE_CHAIN (arg_type);
229 TREE_CHAIN (arg_type) = new_type;
231 arg_type = TREE_CHAIN (arg_type);
232 new_idx++;
234 else if (chkp_type_has_pointer (TREE_VALUE (arg_type)))
236 bitmap slots = BITMAP_ALLOC (NULL);
237 bitmap_iterator bi;
238 unsigned bnd_no;
240 chkp_find_bound_slots (TREE_VALUE (arg_type), slots);
242 EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi)
244 tree new_type = build_tree_list (NULL_TREE,
245 pointer_bounds_type_node);
246 TREE_CHAIN (new_type) = TREE_CHAIN (arg_type);
247 TREE_CHAIN (arg_type) = new_type;
249 arg_type = TREE_CHAIN (arg_type);
250 new_idx++;
252 BITMAP_FREE (slots);
256 /* If function type has attribute with arg indexes then
257 we have to copy it fixing attribute ops. Map for
258 fixing is in indexes array. */
259 attrs = TYPE_ATTRIBUTES (type);
260 if (lookup_attribute ("nonnull", attrs)
261 || lookup_attribute ("format", attrs)
262 || lookup_attribute ("format_arg", attrs))
264 int delta = new_idx - len;
265 attrs = copy_list (TYPE_ATTRIBUTES (type));
266 chkp_map_attr_arg_indexes (attrs, "nonnull", indexes, len, delta);
267 chkp_map_attr_arg_indexes (attrs, "format", indexes, len, delta);
268 chkp_map_attr_arg_indexes (attrs, "format_arg", indexes, len, delta);
269 TYPE_ATTRIBUTES (type) = attrs;
272 t = TYPE_MAIN_VARIANT (orig_type);
273 if (orig_type != t)
275 TYPE_MAIN_VARIANT (type) = t;
276 TYPE_NEXT_VARIANT (type) = TYPE_NEXT_VARIANT (t);
277 TYPE_NEXT_VARIANT (t) = type;
279 else
281 TYPE_MAIN_VARIANT (type) = type;
282 TYPE_NEXT_VARIANT (type) = NULL;
286 return type;
289 /* For given function FNDECL add bounds arguments to arguments
290 list. */
292 static void
293 chkp_add_bounds_params_to_function (tree fndecl)
295 tree arg;
297 for (arg = DECL_ARGUMENTS (fndecl); arg; arg = DECL_CHAIN (arg))
298 if (BOUNDED_P (arg))
300 std::string new_name = CHKP_BOUNDS_OF_SYMBOL_PREFIX;
301 tree new_arg;
303 if (DECL_NAME (arg))
304 new_name += IDENTIFIER_POINTER (DECL_NAME (arg));
305 else
307 char uid[25];
308 snprintf (uid, 25, "D.%u", DECL_UID (arg));
309 new_name += uid;
312 new_arg = build_decl (DECL_SOURCE_LOCATION (arg), PARM_DECL,
313 get_identifier (new_name.c_str ()),
314 pointer_bounds_type_node);
315 DECL_ARG_TYPE (new_arg) = pointer_bounds_type_node;
316 DECL_CONTEXT (new_arg) = DECL_CONTEXT (arg);
317 DECL_ARTIFICIAL (new_arg) = 1;
318 DECL_CHAIN (new_arg) = DECL_CHAIN (arg);
319 DECL_CHAIN (arg) = new_arg;
321 arg = DECL_CHAIN (arg);
324 else if (chkp_type_has_pointer (TREE_TYPE (arg)))
326 tree orig_arg = arg;
327 bitmap slots = BITMAP_ALLOC (NULL);
328 bitmap_iterator bi;
329 unsigned bnd_no;
331 chkp_find_bound_slots (TREE_TYPE (arg), slots);
333 EXECUTE_IF_SET_IN_BITMAP (slots, 0, bnd_no, bi)
335 std::string new_name = CHKP_BOUNDS_OF_SYMBOL_PREFIX;
336 tree new_arg;
337 char offs[25];
339 if (DECL_NAME (orig_arg))
340 new_name += IDENTIFIER_POINTER (DECL_NAME (orig_arg));
341 else
343 snprintf (offs, 25, "D.%u", DECL_UID (arg));
344 new_name += offs;
346 snprintf (offs, 25, "__%u", bnd_no * POINTER_SIZE / BITS_PER_UNIT);
348 new_arg = build_decl (DECL_SOURCE_LOCATION (orig_arg),
349 PARM_DECL,
350 get_identifier (new_name.c_str ()),
351 pointer_bounds_type_node);
352 DECL_ARG_TYPE (new_arg) = pointer_bounds_type_node;
353 DECL_CONTEXT (new_arg) = DECL_CONTEXT (orig_arg);
354 DECL_ARTIFICIAL (new_arg) = 1;
355 DECL_CHAIN (new_arg) = DECL_CHAIN (arg);
356 DECL_CHAIN (arg) = new_arg;
358 arg = DECL_CHAIN (arg);
360 BITMAP_FREE (slots);
363 TREE_TYPE (fndecl) =
364 chkp_copy_function_type_adding_bounds (TREE_TYPE (fndecl));
367 /* Return an instrumentation clone for builtin function
368 FNDECL. Create one if needed. */
370 tree
371 chkp_maybe_clone_builtin_fndecl (tree fndecl)
373 tree clone;
374 enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
376 gcc_assert (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
377 && fcode < BEGIN_CHKP_BUILTINS);
379 fcode = (enum built_in_function) (fcode + BEGIN_CHKP_BUILTINS + 1);
380 clone = builtin_decl_explicit (fcode);
381 if (clone)
382 return clone;
384 clone = chkp_build_instrumented_fndecl (fndecl);
385 chkp_add_bounds_params_to_function (clone);
387 gcc_assert (DECL_FUNCTION_CODE (clone) == fcode);
389 set_builtin_decl (fcode, clone, false);
391 return clone;
394 /* Return clone created for instrumentation of NODE or NULL. */
396 cgraph_node *
397 chkp_maybe_create_clone (tree fndecl)
399 cgraph_node *node = cgraph_node::get_create (fndecl);
400 cgraph_node *clone = node->instrumented_version;
402 gcc_assert (!node->instrumentation_clone);
404 if (DECL_BUILT_IN (fndecl)
405 && (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL
406 || DECL_FUNCTION_CODE (fndecl) >= BEGIN_CHKP_BUILTINS))
407 return NULL;
409 clone = node->instrumented_version;
411 /* Some instrumented builtin function calls may be optimized and
412 cgraph nodes may be removed as unreachable. Later optimizations
413 may generate new calls to removed functions and in this case
414 we have to recreate cgraph node. FUNCTION_DECL for instrumented
415 builtin still exists and should be reused in such case. */
416 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
417 && fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))
418 && !clone)
420 enum built_in_function fncode = DECL_FUNCTION_CODE (fndecl);
421 tree new_decl;
423 fncode = (enum built_in_function) (fncode + BEGIN_CHKP_BUILTINS + 1);
424 new_decl = builtin_decl_explicit (fncode);
426 /* We've actually already created an instrumented clone once.
427 Restore it. */
428 if (new_decl)
430 clone = cgraph_node::get (new_decl);
432 if (!clone)
434 gcc_assert (!gimple_has_body_p (fndecl));
435 clone = cgraph_node::get_create (new_decl);
436 clone->externally_visible = node->externally_visible;
437 clone->local = node->local;
438 clone->address_taken = node->address_taken;
439 clone->thunk = node->thunk;
440 clone->alias = node->alias;
441 clone->weakref = node->weakref;
442 clone->cpp_implicit_alias = node->cpp_implicit_alias;
443 clone->orig_decl = fndecl;
444 clone->instrumentation_clone = true;
447 clone->instrumented_version = node;
448 node->instrumented_version = clone;
452 if (!clone)
454 tree new_decl = chkp_build_instrumented_fndecl (fndecl);
455 struct cgraph_edge *e;
456 struct ipa_ref *ref;
457 int i;
459 clone = node->create_version_clone (new_decl, vNULL, NULL);
460 clone->externally_visible = node->externally_visible;
461 clone->local = node->local;
462 clone->address_taken = node->address_taken;
463 clone->thunk = node->thunk;
464 clone->alias = node->alias;
465 clone->weakref = node->weakref;
466 clone->cpp_implicit_alias = node->cpp_implicit_alias;
467 clone->instrumented_version = node;
468 clone->orig_decl = fndecl;
469 clone->instrumentation_clone = true;
470 node->instrumented_version = clone;
472 if (gimple_has_body_p (fndecl))
474 /* If function will not be instrumented, then it's instrumented
475 version is a thunk for the original. */
476 if (lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl))
477 || (flag_chkp_instrument_marked_only
478 && !lookup_attribute ("bnd_instrument", DECL_ATTRIBUTES (fndecl))))
480 clone->thunk.thunk_p = true;
481 clone->thunk.add_pointer_bounds_args = true;
482 clone->create_edge (node, NULL, 0, CGRAPH_FREQ_BASE);
484 else
486 tree_function_versioning (fndecl, new_decl, NULL, false,
487 NULL, false, NULL, NULL);
488 clone->lowered = true;
492 /* New params are inserted after versioning because it
493 actually copies args list from the original decl. */
494 chkp_add_bounds_params_to_function (new_decl);
496 /* Remember builtin fndecl. */
497 if (DECL_BUILT_IN_CLASS (clone->decl) == BUILT_IN_NORMAL
498 && fndecl == builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
500 gcc_assert (!builtin_decl_explicit (DECL_FUNCTION_CODE (clone->decl)));
501 set_builtin_decl (DECL_FUNCTION_CODE (clone->decl),
502 clone->decl, false);
505 /* Clones have the same comdat group as originals. */
506 if (node->same_comdat_group
507 || DECL_ONE_ONLY (node->decl))
508 clone->add_to_same_comdat_group (node);
510 if (gimple_has_body_p (fndecl))
511 symtab->call_cgraph_insertion_hooks (clone);
513 /* Clone all aliases. */
514 for (i = 0; node->iterate_referring (i, ref); i++)
515 if (ref->use == IPA_REF_ALIAS)
517 struct cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
518 struct cgraph_node *chkp_alias
519 = chkp_maybe_create_clone (alias->decl);
520 chkp_alias->create_reference (clone, IPA_REF_ALIAS, NULL);
523 /* Clone all thunks. */
524 for (e = node->callers; e; e = e->next_caller)
525 if (e->caller->thunk.thunk_p)
527 struct cgraph_node *thunk
528 = chkp_maybe_create_clone (e->caller->decl);
529 /* Redirect thunk clone edge to the node clone. */
530 thunk->callees->redirect_callee (clone);
533 /* For aliases and thunks we should make sure target is cloned
534 to have proper references and edges. */
535 if (node->thunk.thunk_p)
536 chkp_maybe_create_clone (node->callees->callee->decl);
537 else if (node->alias)
539 struct cgraph_node *target;
541 ref = node->ref_list.first_reference ();
542 if (ref)
543 chkp_maybe_create_clone (ref->referred->decl);
545 if (node->alias_target)
547 if (TREE_CODE (node->alias_target) == FUNCTION_DECL)
549 target = chkp_maybe_create_clone (node->alias_target);
550 clone->alias_target = target->decl;
552 else
553 clone->alias_target = node->alias_target;
557 /* Add IPA reference. It's main role is to keep instrumented
558 version reachable while original node is reachable. */
559 ref = node->create_reference (clone, IPA_REF_CHKP, NULL);
562 return clone;
565 /* Create clone for all functions to be instrumented. */
567 static unsigned int
568 chkp_versioning (void)
570 struct cgraph_node *node;
572 bitmap_obstack_initialize (NULL);
574 FOR_EACH_DEFINED_FUNCTION (node)
576 if (!node->instrumentation_clone
577 && !node->instrumented_version
578 && !node->alias
579 && !node->thunk.thunk_p
580 && !lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (node->decl))
581 && (!flag_chkp_instrument_marked_only
582 || lookup_attribute ("bnd_instrument",
583 DECL_ATTRIBUTES (node->decl)))
584 && (!DECL_BUILT_IN (node->decl)
585 || (DECL_BUILT_IN_CLASS (node->decl) == BUILT_IN_NORMAL
586 && DECL_FUNCTION_CODE (node->decl) < BEGIN_CHKP_BUILTINS)))
587 chkp_maybe_create_clone (node->decl);
590 /* Mark all aliases and thunks of functions with no instrumented
591 version as legacy function. */
592 FOR_EACH_DEFINED_FUNCTION (node)
594 if (!node->instrumentation_clone
595 && !node->instrumented_version
596 && (node->alias || node->thunk.thunk_p)
597 && !lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (node->decl)))
598 DECL_ATTRIBUTES (node->decl)
599 = tree_cons (get_identifier ("bnd_legacy"), NULL,
600 DECL_ATTRIBUTES (node->decl));
603 bitmap_obstack_release (NULL);
605 return 0;
608 /* In this pass we remove bodies of functions having
609 instrumented version. Functions with removed bodies
610 become a special kind of thunks to provide a connection
611 between calls to the original version and instrumented
612 function. */
614 static unsigned int
615 chkp_produce_thunks (void)
617 struct cgraph_node *node;
619 FOR_EACH_DEFINED_FUNCTION (node)
621 if (!node->instrumentation_clone
622 && node->instrumented_version
623 && gimple_has_body_p (node->decl)
624 && gimple_has_body_p (node->instrumented_version->decl))
626 node->release_body ();
627 node->remove_callees ();
628 node->remove_all_references ();
630 node->thunk.thunk_p = true;
631 node->thunk.add_pointer_bounds_args = true;
632 node->create_edge (node->instrumented_version, NULL,
633 0, CGRAPH_FREQ_BASE);
634 node->create_reference (node->instrumented_version,
635 IPA_REF_CHKP, NULL);
639 /* Mark instrumentation clones created for aliases and thunks
640 as insttrumented so they could be removed as unreachable
641 now. */
642 FOR_EACH_DEFINED_FUNCTION (node)
644 if (node->instrumentation_clone
645 && (node->alias || node->thunk.thunk_p)
646 && !chkp_function_instrumented_p (node->decl))
647 chkp_function_mark_instrumented (node->decl);
650 symtab->remove_unreachable_nodes (true, dump_file);
652 return 0;
655 const pass_data pass_data_ipa_chkp_versioning =
657 SIMPLE_IPA_PASS, /* type */
658 "chkp_versioning", /* name */
659 OPTGROUP_NONE, /* optinfo_flags */
660 TV_NONE, /* tv_id */
661 0, /* properties_required */
662 0, /* properties_provided */
663 0, /* properties_destroyed */
664 0, /* todo_flags_start */
665 0 /* todo_flags_finish */
668 const pass_data pass_data_ipa_chkp_produce_thunks =
670 SIMPLE_IPA_PASS, /* type */
671 "chkp_cleanup", /* name */
672 OPTGROUP_NONE, /* optinfo_flags */
673 TV_NONE, /* tv_id */
674 0, /* properties_required */
675 0, /* properties_provided */
676 0, /* properties_destroyed */
677 0, /* todo_flags_start */
678 0 /* todo_flags_finish */
681 class pass_ipa_chkp_versioning : public simple_ipa_opt_pass
683 public:
684 pass_ipa_chkp_versioning (gcc::context *ctxt)
685 : simple_ipa_opt_pass (pass_data_ipa_chkp_versioning, ctxt)
688 /* opt_pass methods: */
689 virtual opt_pass * clone ()
691 return new pass_ipa_chkp_versioning (m_ctxt);
694 virtual bool gate (function *)
696 return flag_check_pointer_bounds;
699 virtual unsigned int execute (function *)
701 return chkp_versioning ();
704 }; // class pass_ipa_chkp_versioning
706 class pass_ipa_chkp_produce_thunks : public simple_ipa_opt_pass
708 public:
709 pass_ipa_chkp_produce_thunks (gcc::context *ctxt)
710 : simple_ipa_opt_pass (pass_data_ipa_chkp_produce_thunks, ctxt)
713 /* opt_pass methods: */
714 virtual opt_pass * clone ()
716 return new pass_ipa_chkp_produce_thunks (m_ctxt);
719 virtual bool gate (function *)
721 return flag_check_pointer_bounds;
724 virtual unsigned int execute (function *)
726 return chkp_produce_thunks ();
729 }; // class pass_chkp_produce_thunks
731 simple_ipa_opt_pass *
732 make_pass_ipa_chkp_versioning (gcc::context *ctxt)
734 return new pass_ipa_chkp_versioning (ctxt);
737 simple_ipa_opt_pass *
738 make_pass_ipa_chkp_produce_thunks (gcc::context *ctxt)
740 return new pass_ipa_chkp_produce_thunks (ctxt);