1 /* { dg-options "-O" } */
3 /* Mark all CALL_EXPRs not within "main" as requiring tail-call. */
5 #include "gcc-plugin.h"
11 #include "stringpool.h"
13 #include "basic-block.h"
14 #include "hash-table.h"
17 #include "basic-block.h"
18 #include "tree-ssa-alias.h"
19 #include "internal-fn.h"
20 #include "gimple-fold.h"
22 #include "gimple-expr.h"
25 #include "tree-pass.h"
27 #include "plugin-version.h"
29 int plugin_is_GPL_compatible
;
32 cb_walk_tree_fn (tree
* tp
, int * walk_subtrees
,
33 void * data ATTRIBUTE_UNUSED
)
35 if (TREE_CODE (*tp
) != CALL_EXPR
)
40 /* Forcibly mark the CALL_EXPR as requiring tail-call optimization. */
41 CALL_EXPR_MUST_TAIL_CALL (call_expr
) = 1;
47 callback (void *gcc_data
, void *user_data
)
49 tree fndecl
= (tree
)gcc_data
;
50 gcc_assert (TREE_CODE (fndecl
) == FUNCTION_DECL
);
52 /* Don't mark calls inside "main". */
53 tree decl_name
= DECL_NAME (fndecl
);
55 if (0 == strcmp (IDENTIFIER_POINTER (decl_name
), "main"))
58 walk_tree (&DECL_SAVED_TREE (fndecl
), cb_walk_tree_fn
, NULL
, NULL
);
62 plugin_init (struct plugin_name_args
*plugin_info
,
63 struct plugin_gcc_version
*version
)
65 const char *plugin_name
= plugin_info
->base_name
;
67 if (!plugin_default_version_check (version
, &gcc_version
))
70 register_callback (plugin_name
,
71 PLUGIN_PRE_GENERICIZE
,