- assemble_variable (gcov_info, 0, 0, 0);
-
- /* Build the constructor function to invoke __gcov_init. */
- ctor_name = concat (IDENTIFIER_POINTER (get_file_function_name ('I')),
- "_GCOV", NULL);
- ctor = build_decl (FUNCTION_DECL, get_identifier (ctor_name),
- build_function_type (void_type_node, NULL_TREE));
- free (ctor_name);
- DECL_EXTERNAL (ctor) = 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 (ctor) = ! targetm.have_ctors_dtors;
- TREE_USED (ctor) = 1;
- DECL_RESULT (ctor) = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
-
- ctor = (*lang_hooks.decls.pushdecl) (ctor);
- rest_of_decl_compilation (ctor, 0, 1, 0);
- announce_function (ctor);
- current_function_decl = ctor;
- DECL_INITIAL (ctor) = error_mark_node;
- make_decl_rtl (ctor, NULL);
- init_function_start (ctor, input_filename, input_line);
- (*lang_hooks.decls.pushlevel) (0);
- expand_function_start (ctor, 0);
- cfun->arc_profile = 0;
-
- /* Actually generate the code to call __gcov_init. */
- gcov_info_address = force_reg (Pmode, XEXP (DECL_RTL (gcov_info), 0));
- emit_library_call (gcov_init_libfunc, LCT_NORMAL, VOIDmode, 1,
- gcov_info_address, Pmode);
-
- expand_function_end (input_filename, input_line, 0);
- (*lang_hooks.decls.poplevel) (1, 0, 1);
-
- /* Since ctor 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 (ctor);
-
- /* 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 (ctor), 0),
- DEFAULT_INIT_PRIORITY);
+ varpool_finalize_decl (gcov_info);
+
+ /* Build a decl for __gcov_init. */
+ t = build_pointer_type (TREE_TYPE (gcov_info));
+ t = build_function_type_list (void_type_node, t, NULL);
+ t = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier ("__gcov_init"), t);
+ TREE_PUBLIC (t) = 1;
+ DECL_EXTERNAL (t) = 1;
+ DECL_ASSEMBLER_NAME (t); /* Initialize assembler name so we can stream out. */
+ gcov_init = t;
+
+ /* Generate a call to __gcov_init(&gcov_info). */
+ body = NULL;
+ t = build_fold_addr_expr (gcov_info);
+ t = build_call_expr (gcov_init, 1, t);
+ append_to_statement_list (t, &body);
+
+ /* Generate a constructor to run it. */
+ cgraph_build_static_cdtor ('I', body, DEFAULT_INIT_PRIORITY);