diff mbox series

PR tree-optimization/84225: do not pass non-integers to operation_no_trapping_overflow

Message ID c745f94e-0165-573a-16d7-3b33ab98d54e@redhat.com
State New
Headers show
Series PR tree-optimization/84225: do not pass non-integers to operation_no_trapping_overflow | expand

Commit Message

Aldy Hernandez Feb. 6, 2018, 3:43 p.m. UTC
In this PR we are ICEing here:

bool
operation_no_trapping_overflow (tree type, enum tree_code code)
{
   gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));

...because we are being passed a pointer type from find_trapping_overflow.

Fixed by avoiding passing non-integrals from find_trapping_overflow.

Pre-approved by Jakub.  Committed.

Tested on x86-64 Linux.

Comments

Jakub Jelinek Feb. 6, 2018, 3:52 p.m. UTC | #1
On Tue, Feb 06, 2018 at 10:43:21AM -0500, Aldy Hernandez wrote:
> In this PR we are ICEing here:
> 
> bool
> operation_no_trapping_overflow (tree type, enum tree_code code)
> {
>   gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));
> 
> ...because we are being passed a pointer type from find_trapping_overflow.
> 
> Fixed by avoiding passing non-integrals from find_trapping_overflow.
> 
> Pre-approved by Jakub.  Committed.
> 
> Tested on x86-64 Linux.

> gcc/
> 
> 	PR tree-optimization/84225
> 	* tree-eh.c (find_trapping_overflow): Only call
> 	operation_no_trapping_overflow when ANY_INTEGRAL_TYPE_P.

Can you please add a testcase too?
While the reported ICE was on an existing testcase, it was with
non-standard options on it.
So e.g.
gcc.dg/pr84225.c
that would contain:

/* PR tree-optimization/84225 */
/* { dg-do compile { target int32plus } } */
/* { dg-options "-Ofast -ftrapv" } */

#include "torture/pr69714.c"

or so should hopefully do the job, just test with cc1 before and after this
change to verify it ICEd and doesn't ICE anymore.

	Jakub
Aldy Hernandez Feb. 6, 2018, 5:10 p.m. UTC | #2
On 02/06/2018 10:52 AM, Jakub Jelinek wrote:
> On Tue, Feb 06, 2018 at 10:43:21AM -0500, Aldy Hernandez wrote:
>> In this PR we are ICEing here:
>>
>> bool
>> operation_no_trapping_overflow (tree type, enum tree_code code)
>> {
>>    gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));
>>
>> ...because we are being passed a pointer type from find_trapping_overflow.
>>
>> Fixed by avoiding passing non-integrals from find_trapping_overflow.
>>
>> Pre-approved by Jakub.  Committed.
>>
>> Tested on x86-64 Linux.
> 
>> gcc/
>>
>> 	PR tree-optimization/84225
>> 	* tree-eh.c (find_trapping_overflow): Only call
>> 	operation_no_trapping_overflow when ANY_INTEGRAL_TYPE_P.
> 
> Can you please add a testcase too?
> While the reported ICE was on an existing testcase, it was with
> non-standard options on it.
> So e.g.
> gcc.dg/pr84225.c
> that would contain:
> 
> /* PR tree-optimization/84225 */
> /* { dg-do compile { target int32plus } } */
> /* { dg-options "-Ofast -ftrapv" } */
> 
> #include "torture/pr69714.c"

Sorry for being sloppy on this.  I didn't even know we could #include 
other tests without the dg-do stuff being included and messing things up.

I have committed the code below, and have verified that it passes with 
the previous patch, and ICEs without the patch.

Thanks.

commit e783f8fb7d9a7b0972b4ebe4b86aa541904de692 (HEAD -> 
pr84225-jakub-trapv)
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Feb 6 12:06:40 2018 -0500

     PR tree-optimization/84225
     Add test for previous commit for PR84225.

diff --git a/gcc/testsuite/gcc.dg/pr84225.c b/gcc/testsuite/gcc.dg/pr84225.c
new file mode 100644
index 00000000000..f57266c9a26
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr84225.c
@@ -0,0 +1,5 @@
+/* PR tree-optimization/84225 */
+/* { dg-do compile { target int32plus } } */
+/* { dg-options "-Ofast -ftrapv" } */
+
+#include "torture/pr69714.c"
diff mbox series

Patch

gcc/

	PR tree-optimization/84225
	* tree-eh.c (find_trapping_overflow): Only call
	operation_no_trapping_overflow when ANY_INTEGRAL_TYPE_P.

diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 75385f7b53f..9862ed9fdda 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -2729,6 +2729,7 @@  static tree
 find_trapping_overflow (tree *tp, int *walk_subtrees, void *data)
 {
   if (EXPR_P (*tp)
+      && ANY_INTEGRAL_TYPE_P (TREE_TYPE (*tp))
       && !operation_no_trapping_overflow (TREE_TYPE (*tp), TREE_CODE (*tp)))
     return *tp;
   if (IS_TYPE_OR_DECL_P (*tp)