This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] genrecog: Fix crash on invalid input
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, rdsandiford at googlemail dot com
- Date: Mon, 14 Mar 2016 15:00:00 -0500
- Subject: Re: [PATCH] genrecog: Fix crash on invalid input
- Authentication-results: sourceware.org; auth=none
- References: <503d8081adff0ecb4a52ab0d3d96ae0771da1995 dot 1457969588 dot git dot segher at kernel dot crashing dot org> <56E6F740 dot 2070007 at redhat dot com> <20160314184138 dot GA21930 at gate dot crashing dot org>
On Mon, Mar 14, 2016 at 01:41:38PM -0500, Segher Boessenkool wrote:
> On Mon, Mar 14, 2016 at 06:39:12PM +0100, Bernd Schmidt wrote:
> > On 03/14/2016 04:38 PM, Segher Boessenkool wrote:
> > >If your machine description refers to a non-existent predicate genrecog
> > >crashes. This fixes it.
> >
> > Might be better to fix the caller?
>
> Yeah maybe. The next function that takes a pred also tests for !pred,
> but let me see what the caller of the failing case is.
There is just the single caller, and pred is set right before the call
there. How about this patch, then?
Segher
Subject: [PATCH] genrecog: Fix crash on invalid input
If your machine description refers to a non-existent predicate genrecog
crashes. This fixes it.
2016-03-14 Segher Boeesenkool <segher#kernel.crashing.org>
* genrecog.c (match_pattern_2): If pred is NULL don't call
safe_predicate_mode on it.
---
gcc/genrecog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index f8b8ef4..47e4266 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -4037,7 +4037,7 @@ match_pattern_2 (state *s, md_rtx_info *info, position *pos, rtx pattern)
/* Check the mode first, to distinguish things like SImode
and DImode register_operands, as described above. */
machine_mode mode = GET_MODE (e->pattern);
- if (safe_predicate_mode (pred, mode))
+ if (pred && safe_predicate_mode (pred, mode))
s = add_decision (s, rtx_test::mode (e->pos), mode, true);
/* Assign to operands[] first, so that the rtx usually doesn't
--
1.9.3