This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015)
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <jh at suse dot cz>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Fri, 20 Dec 2019 16:11:29 +0100
- Subject: [PATCH] Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015)
Hi,
PR 93015 testcase - an empty main function compiled with -O0 -fipa-vrp
-flto - shows that IPA-VRA can segfault when trying to access results of
an analysis that has not been performed because of zero optimization
level, -fno-ipa-cp etc.
Rather than adding another chain of opt_for_fn() the patch fixes it by
what IPA-CP-BITS does, which is simply checking that info of a node is
not NULL.
Bootstrapped and tested on x86_64-linux. OK for trunk?
Thanks,
Martin
2019-12-20 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.
---
gcc/ipa-cp.c | 2 +-
gcc/testsuite/gcc.dg/lto/pr93015_0.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/lto/pr93015_0.c
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 243b064ee2c..329e259ede3 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 (!info || !opt_for_fn (node->decl, flag_ipa_vrp))
{
if (dump_file)
fprintf (dump_file, "Not considering %s for VR discovery "
diff --git a/gcc/testsuite/gcc.dg/lto/pr93015_0.c b/gcc/testsuite/gcc.dg/lto/pr93015_0.c
new file mode 100644
index 00000000000..d084b5ad1e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr93015_0.c
@@ -0,0 +1,6 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -O0 -fipa-vrp -flto } } } */
+
+int main() {
+
+}
--
2.24.0