- tree fnname, fndecl;
- char *name;
- char buf[20];
- const char *cfnname;
- rtx table_address;
- enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
- int save_flag_inline_functions = flag_inline_functions;
-
- /* It's either already been output, or we don't need it because we're
- not doing profile-edges. */
- if (! need_func_profiler)
- return;
-
- need_func_profiler = 0;
-
- /* Synthesize a constructor function to invoke __bb_init_func with a
- pointer to this object file's profile block. */
-
- /* Try and make a unique name given the "file function name".
-
- And no, I don't like this either. */
-
- fnname = get_file_function_name ('I');
- cfnname = IDENTIFIER_POINTER (fnname);
- name = concat (cfnname, "GCOV", NULL);
- fnname = get_identifier (name);
- free (name);
-
- fndecl = build_decl (FUNCTION_DECL, fnname,
- build_function_type (void_type_node, NULL_TREE));
- DECL_EXTERNAL (fndecl) = 0;
-
- /* It can be a static function as long as collect2 does not have
- to scan the object file to find its ctor/dtor routine. */
- TREE_PUBLIC (fndecl) = ! targetm.have_ctors_dtors;
-
- TREE_USED (fndecl) = 1;
-
- DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
-
- fndecl = (*lang_hooks.decls.pushdecl) (fndecl);
- rest_of_decl_compilation (fndecl, 0, 1, 0);
- announce_function (fndecl);
- current_function_decl = fndecl;
- DECL_INITIAL (fndecl) = error_mark_node;
- make_decl_rtl (fndecl, NULL);
- init_function_start (fndecl, input_filename, lineno);
- (*lang_hooks.decls.pushlevel) (0);
- expand_function_start (fndecl, 0);
- cfun->arc_profile = 0;
-
- /* Actually generate the code to call __bb_init_func. */
- ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", 0);
- table_address = force_reg (Pmode,
- gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf)));
- emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__bb_init_func"), LCT_NORMAL,
- mode, 1, table_address, Pmode);
-
- expand_function_end (input_filename, lineno, 0);
- (*lang_hooks.decls.poplevel) (1, 0, 1);
-
- /* Since fndecl isn't in the list of globals, it would never be emitted
- when it's considered to be 'safe' for inlining, so turn off
- flag_inline_functions. */
- flag_inline_functions = 0;
-
- rest_of_compilation (fndecl);
-
- /* Reset flag_inline_functions to its original value. */
- flag_inline_functions = save_flag_inline_functions;
-
- if (! quiet_flag)
- fflush (asm_out_file);
- current_function_decl = NULL_TREE;
-
- if (targetm.have_ctors_dtors)
- (* targetm.asm_out.constructor) (XEXP (DECL_RTL (fndecl), 0),
- DEFAULT_INIT_PRIORITY);