From c04d26729def4384a829cb1c4a403c997b33a74a Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 30 Jan 2017 15:35:57 +0000 Subject: [PATCH] Fix profile corruption with -O1 (PR gcov-profile/79259) 2017-01-30 Martin Liska PR gcov-profile/79259 * opts.c (common_handle_option): Enable flag_ipa_bit_cp w/ -fprofile-generate. 2017-01-30 Martin Liska PR gcov-profile/79259 * g++.dg/tree-prof/pr79259.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245031 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/opts.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-prof/pr79259.C | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/g++.dg/tree-prof/pr79259.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 620c4b09eba..206b8a59c41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2017-01-30 Martin Liska + PR gcov-profile/79259 + * opts.c (common_handle_option): Enable flag_ipa_bit_cp w/ + -fprofile-generate. + +2017-01-30 Martin Liska + PR bootstrap/78985 * config/aarch64/cortex-a57-fma-steering.c (func_fma_steering::analyze): Initialize variables with NULL value. diff --git a/gcc/opts.c b/gcc/opts.c index 5f573a16ff1..b38e9b4f3a7 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2150,6 +2150,8 @@ common_handle_option (struct gcc_options *opts, opts->x_flag_profile_values = value; if (!opts_set->x_flag_inline_functions) opts->x_flag_inline_functions = value; + if (!opts_set->x_flag_ipa_bit_cp) + opts->x_flag_ipa_bit_cp = value; /* FIXME: Instrumentation we insert makes ipa-reference bitmaps quadratic. Disable the pass until better memory representation is done. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 33f02489e4e..cbab69fd1b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-30 Martin Liska + + PR gcov-profile/79259 + * g++.dg/tree-prof/pr79259.C: New test. + 2017-01-30 Richard Biener PR tree-optimization/79276 diff --git a/gcc/testsuite/g++.dg/tree-prof/pr79259.C b/gcc/testsuite/g++.dg/tree-prof/pr79259.C new file mode 100644 index 00000000000..a55172b62d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/pr79259.C @@ -0,0 +1,20 @@ +/* { dg-options "-O1" } */ + +inline bool +a (int b) +{ + return (b & 5) != b; +} +int c; +int +fn2 () +{ + if (a (c == 0)) + return 0; +} + +int main() +{ + fn2(); +} + -- 2.11.4.GIT