From 2d799bac340201721d62f4bbf5e54195ec2bf144 Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 25 Nov 2016 14:23:25 +0000 Subject: Don't use priority {cd}tors if not supported by a target (PR PR gcov-profile/78086 * g++.dg/gcov/pr16855.C: Clean up the test case. * g++.dg/gcov/pr16855-priority.C: New test. * coverage.c (build_init_ctor): Don't use priority {cd}tors if not supported by a target. Set priority to 100 if possible. (build_gcov_exit_decl): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242877 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/coverage.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'gcc/coverage.c') diff --git a/gcc/coverage.c b/gcc/coverage.c index 8810710be4f..4167e26b208 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -1056,8 +1056,10 @@ build_init_ctor (tree gcov_info_type) stmt = build_call_expr (init_fn, 1, stmt); append_to_statement_list (stmt, &ctor); - /* Generate a constructor to run it (with priority 99). */ - cgraph_build_static_cdtor ('I', ctor, DEFAULT_INIT_PRIORITY - 1); + /* Generate a constructor to run it. */ + int priority = SUPPORTS_INIT_PRIORITY + ? MAX_RESERVED_INIT_PRIORITY: DEFAULT_INIT_PRIORITY; + cgraph_build_static_cdtor ('I', ctor, priority); } /* Generate the destructor function to call __gcov_exit. */ @@ -1078,8 +1080,11 @@ build_gcov_exit_decl (void) tree stmt = build_call_expr (init_fn, 0); append_to_statement_list (stmt, &dtor); - /* Generate a destructor to run it (with priority 99). */ - cgraph_build_static_cdtor ('D', dtor, MAX_RESERVED_INIT_PRIORITY - 1); + /* Generate a destructor to run it. */ + int priority = SUPPORTS_INIT_PRIORITY + ? MAX_RESERVED_INIT_PRIORITY: DEFAULT_INIT_PRIORITY; + + cgraph_build_static_cdtor ('D', dtor, priority); } /* Create the gcov_info types and object. Generate the constructor -- cgit v1.2.1