/* extern void __mf_init (); */
static GTY (()) tree mf_init_fndecl;
+/* extern int __mf_set_options (const char*); */
+static GTY (()) tree mf_set_options_fndecl;
+
+
/* Helper for mudflap_init: construct a decl with the given category,
name, and type, mark it an external reference, and pushdecl it. */
static inline tree
#define build_function_type_0(rtype) \
build_function_type (rtype, void_list_node)
+#define build_function_type_1(rtype, arg1) \
+ build_function_type (rtype, tree_cons (0, arg1, void_list_node))
#define build_function_type_3(rtype, arg1, arg2, arg3) \
build_function_type (rtype, tree_cons (0, arg1, tree_cons (0, arg2, \
tree_cons (0, arg3, void_list_node))))
tree mf_check_register_fntype;
tree mf_unregister_fntype;
tree mf_init_fntype;
+ tree mf_set_options_fntype;
if (done)
return;
integer_type_node);
mf_init_fntype =
build_function_type_0 (void_type_node);
+ mf_set_options_fntype =
+ build_function_type_1 (integer_type_node, mf_const_string_type);
mf_cache_array_decl = mf_make_builtin (VAR_DECL, "__mf_lookup_cache",
mf_cache_array_type);
mf_unregister_fntype);
mf_init_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_init",
mf_init_fntype);
+ mf_set_options_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_set_options",
+ mf_set_options_fntype);
}
#undef build_function_type_4
#undef build_function_type_3
+#undef build_function_type_1
#undef build_function_type_0
call_stmt = build_function_call_expr (mf_register_fndecl, args);
- /* Add an initial __mf_init() call to the list of registration calls. */
- if (enqueued_call_stmt_chain == NULL_TREE)
- {
- tree call2_stmt = build_function_call_expr (mf_init_fndecl, NULL_TREE);
- append_to_statement_list (call2_stmt, &enqueued_call_stmt_chain);
- }
-
append_to_statement_list (call_stmt, &enqueued_call_stmt_chain);
}
void
mudflap_finish_file (void)
{
+ tree ctor_statements = NULL_TREE;
+
/* Try to give the deferred objects one final try. */
if (deferred_static_decls)
{
VARRAY_CLEAR (deferred_static_decls);
}
+ /* Insert a call to __mf_init. */
+ {
+ tree call2_stmt = build_function_call_expr (mf_init_fndecl, NULL_TREE);
+ append_to_statement_list (call2_stmt, &ctor_statements);
+ }
+
+ /* If appropriate, call __mf_set_options to pass along read-ignore mode. */
+ if (flag_mudflap_ignore_reads)
+ {
+ tree arg = tree_cons (NULL_TREE,
+ mf_build_string ("-ignore-reads"), NULL_TREE);
+ tree call_stmt = build_function_call_expr (mf_set_options_fndecl, arg);
+ append_to_statement_list (call_stmt, &ctor_statements);
+ }
+
+ /* Append all the enqueued registration calls. */
if (enqueued_call_stmt_chain)
{
- cgraph_build_static_cdtor ('I', enqueued_call_stmt_chain,
- MAX_RESERVED_INIT_PRIORITY-1);
- enqueued_call_stmt_chain = 0;
+ append_to_statement_list (enqueued_call_stmt_chain, &ctor_statements);
+ enqueued_call_stmt_chain = NULL_TREE;
}
+
+ cgraph_build_static_cdtor ('I', ctor_statements,
+ MAX_RESERVED_INIT_PRIORITY-1);
}