Bug 93015 - [10 Regression] Segmentation fault (ipcp_store_vr_results(void))
Summary: [10 Regression] Segmentation fault (ipcp_store_vr_results(void))
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 10.0
Assignee: Martin Jambor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-19 17:11 UTC by 吳建興
Modified: 2020-01-03 13:43 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-12-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 吳建興 2019-12-19 17:11:17 UTC
g++ -fipa-vrp  -fipa-pta -fipa-cp  -flto ./hi.c

INPUT :
./hi.c

int main() {

}

OUTPUT :

during IPA pass: cp
lto1: internal compiler error: Segmentation fault
0x268adb9 crash_signal
        ../.././gcc/toplev.c:328
0x5394138 ipcp_store_vr_results
        ../.././gcc/ipa-cp.c:5673
0x5394138 ipcp_driver
        ../.././gcc/ipa-cp.c:5752

Version:
g++ (GCC) 10.0.0 20191218 (experimental)
Comment 1 Jakub Jelinek 2019-12-19 19:50:33 UTC
Works fine with 6/7/8/9 branches, as it is on the lto1 side, can't unfortunately bisect.
Comment 2 Martin Jambor 2019-12-20 09:29:21 UTC
Heh, ipcp_store_vr_results checks for flag_ipa_vrp but not for flag_ipa_cp or optimize, which means that it accesses info which has not been created.  I suppose it's best to do what ipcp_store_bits_results does:

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 243b064ee2c..a29e96613a3 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -5661,7 +5661,7 @@ ipcp_store_vr_results (void)
       ipa_node_params *info = IPA_NODE_REF (node);
       bool found_useful_result = false;
 
-      if (!opt_for_fn (node->decl, flag_ipa_vrp))
+      if (!opt_for_fn (node->decl, flag_ipa_vrp) || !info)
        {
          if (dump_file)
            fprintf (dump_file, "Not considering %s for VR discovery "
Comment 3 Martin Jambor 2019-12-20 15:46:38 UTC
I proposed a patch on the mailing list:

https://gcc.gnu.org/ml/gcc-patches/2019-12/msg01451.html
Comment 4 Martin Jambor 2019-12-21 11:25:36 UTC
Author: jamborm
Date: Sat Dec 21 11:25:05 2019
New Revision: 279695

URL: https://gcc.gnu.org/viewcvs?rev=279695&root=gcc&view=rev
Log:
Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015)

2019-12-21  Martin Jambor  <mjambor@suse.cz>

	PR ipa/93015
	* ipa-cp.c (ipcp_store_vr_results): Check that info exists

	testsuite/
	* gcc.dg/lto/pr93015_0.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/lto/pr93015_0.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-cp.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Martin Jambor 2020-01-03 13:43:54 UTC
Should be fixed now.