Message ID | nycvar.YFH.7.76.2005041407260.4397@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
Series | Adjust integer <-> pointer conversion IL checking | expand |
On Mon, 2020-05-04 at 14:11 +0200, Richard Biener wrote: > This patch sits in my trees for quite some years and I always forget > to push it - it usually gets triggered by weird targets (PSImode > pointers/sizetype) which run into GIMPLE IL checking asserts for > pointer -> integer conversions and the "sizetype" special-case > not triggering. That special-case should not exist but instead > it should be something like the patch below - the whole point > of the IL consistecy check is to ensure we know how to extend > from pointer to integer. > > I've bootstrapped / tested the patch on x86_64 where it is a no-op. > > But from the looks, can you punch any holes in it? (it was able > to resolve reporters issues at least). > > Thanks, > Richard. > > - > > The existing check doesn't reflect the actual reason why it exists, > the patch makes us to use POINTERS_EXTEND_UNSIGNED instead which > is specified for ptr_mode and word_mode/Pmode precision. > > * tree-cfg.c (verify_gimple_assign_unary): Adjust integer > to/from pointer conversion checking. I'd say let's go for it. The tester will pick it up and I'll complain if any of the targets start failing. jeff >
On Tue, 5 May 2020, Jeff Law wrote: > On Mon, 2020-05-04 at 14:11 +0200, Richard Biener wrote: > > This patch sits in my trees for quite some years and I always forget > > to push it - it usually gets triggered by weird targets (PSImode > > pointers/sizetype) which run into GIMPLE IL checking asserts for > > pointer -> integer conversions and the "sizetype" special-case > > not triggering. That special-case should not exist but instead > > it should be something like the patch below - the whole point > > of the IL consistecy check is to ensure we know how to extend > > from pointer to integer. > > > > I've bootstrapped / tested the patch on x86_64 where it is a no-op. > > > > But from the looks, can you punch any holes in it? (it was able > > to resolve reporters issues at least). > > > > Thanks, > > Richard. > > > > - > > > > The existing check doesn't reflect the actual reason why it exists, > > the patch makes us to use POINTERS_EXTEND_UNSIGNED instead which > > is specified for ptr_mode and word_mode/Pmode precision. > > > > * tree-cfg.c (verify_gimple_assign_unary): Adjust integer > > to/from pointer conversion checking. > I'd say let's go for it. The tester will pick it up and I'll complain if any of > the targets start failing. Fair enough - I've pushed the patch. Richard.
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e99fb9ff5d1..c6140af50e7 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3591,13 +3591,21 @@ verify_gimple_assign_unary (gassign *stmt) /* Allow conversions from pointer type to integral type only if there is no sign or zero extension involved. For targets were the precision of ptrofftype doesn't match that - of pointers we need to allow arbitrary conversions to ptrofftype. */ + of pointers we allow conversions to types where + POINTERS_EXTEND_UNSIGNED specifies how that works. */ if ((POINTER_TYPE_P (lhs_type) && INTEGRAL_TYPE_P (rhs1_type)) || (POINTER_TYPE_P (rhs1_type) && INTEGRAL_TYPE_P (lhs_type) && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type) - || ptrofftype_p (lhs_type)))) +#if defined(POINTERS_EXTEND_UNSIGNED) + || (TYPE_MODE (rhs1_type) == ptr_mode + && (TYPE_PRECISION (lhs_type) + == BITS_PER_WORD /* word_mode */ + || (TYPE_PRECISION (lhs_type) + == GET_MODE_PRECISION (Pmode)))) +#endif + ))) return false; /* Allow conversion from integral to offset type and vice versa. */