Message ID | ri6woarm3q6.fsf@suse.cz |
---|---|
State | New |
Headers | show |
Series | Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015) | expand |
> 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. OK, thanks! Honza
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() { + +}