On Thu, Apr 29, 2021 at 8:52 AM Jeff Law <jeffreya...@gmail.com> wrote:
>
> This change:
>
> 985b3a6837dee7001e6b618f073ed74f0edf5787 is the first bad commit
> commit 985b3a6837dee7001e6b618f073ed74f0edf5787
> Author: H.J. Lu <hjl.to...@gmail.com>
> Date:   Mon Jun 10 09:57:15 2019 -0700
>
>      Generate offset adjusted operation for op_by_pieces operations
>
>      Add an overlap_op_by_pieces_p target hook for op_by_pieces operations
>      between two areas of memory to generate one offset adjusted operation
>      in the smallest integer mode for the remaining bytes on the last piece
>      operation of a memory region to avoid doing more than one smaller
>      operations.
>
>      Pass the RTL information from the previous iteration to m_constfn in
>      op_by_pieces operation so that builtin_memset_[read|gen]_str can
>      generate the new RTL from the previous RTL.
>
>      Tested on Linux/x86-64.
>
>      gcc/
>
>              PR middle-end/90773
>              * builtins.c (builtin_memcpy_read_str): Add a dummy argument.
>              (builtin_strncpy_read_str): Likewise.
>              (builtin_memset_read_str): Add an argument for the previous RTL
>              information and generate the new RTL from the previous RTL
> info.
>              (builtin_memset_gen_str): Likewise.
>              * builtins.h (builtin_strncpy_read_str): Update the prototype.
>              (builtin_memset_read_str): Likewise.
>              * expr.c (by_pieces_ninsns): If
> targetm.overlap_op_by_pieces_p()
>              returns true, round up size and alignment to the widest integer
>              mode for maximum size.
>              (pieces_addr::adjust): Add a pointer to by_pieces_prev argument
>              and pass it to m_constfn.
>              (op_by_pieces_d): Add m_push and m_overlap_op_by_pieces.
>              (op_by_pieces_d::op_by_pieces_d): Add a bool argument to
>              initialize m_push.  Initialize m_overlap_op_by_pieces with
>              targetm.overlap_op_by_pieces_p ().
>              (op_by_pieces_d::run): Pass the previous RTL information to
>              pieces_addr::adjust and generate overlapping operations if
>              m_overlap_op_by_pieces is true.
>              (PUSHG_P): New.
>              (move_by_pieces_d::move_by_pieces_d): Updated for
> op_by_pieces_d
>              change.
>              (store_by_pieces_d::store_by_pieces_d): Updated for
> op_by_pieces_d
>              change.
>              (can_store_by_pieces): Use by_pieces_constfn on constfun.
>              (store_by_pieces): Use by_pieces_constfn on constfun. Updated
>              for op_by_pieces_d change.
>              (clear_by_pieces_1): Add a dummy argument.
>              (clear_by_pieces): Updated for op_by_pieces_d change.
>              (compare_by_pieces_d::compare_by_pieces_d): Likewise.
>              (string_cst_read_str): Add a dummy argument.
>              * expr.h (by_pieces_constfn): Add a dummy argument.
>              (by_pieces_prev): New.
>              * target.def (overlap_op_by_pieces_p): New target hook.
>              * config/i386/i386.c (TARGET_OVERLAP_OP_BY_PIECES_P): New.
>              * doc/tm.texi.in: Add TARGET_OVERLAP_OP_BY_PIECES_P.
>              * doc/tm.texi: Regenerated.
>
>
> Is causing regressions on the fr30-elf port:
>
>
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 168)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 174)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 180)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 186)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 193)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 201)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 265)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 274)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 282)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c  (test for warnings, line 289)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c (test for excess errors)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c malloc note (test for warnings,
> line 288)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c note (test for warnings, line 264)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c note (test for warnings, line 273)
> fr30-sim: gcc.dg/Wstringop-overflow-27.c vla note (test for warnings,
> line 281)
>
>
> I haven't done any analysis other then bisecting the regression.
>
>
> Full logs are here:
>
> http://3.14.90.209:8080/job/fr30-elf/1258/console
>

Check nullptr return from simplify_gen_subreg.  Don't use it if it is
nullptr.

OK for master?

Thanks.

-- 
H.J.
From 7722dc817fb413f5a4887c8a38ab7b30ab39a33b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 29 Apr 2021 11:12:09 -0700
Subject: [PATCH] Don't use nullptr return from simplify_gen_subreg

Check nullptr return from simplify_gen_subreg.  Don't use it if it is
nullptr.

	PR middle-end/90773
	* builtins.c (builtin_memset_gen_str): Don't use return from
	simplify_gen_subreg.
---
 gcc/builtins.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 2d6bf4a65b4..4613aecfe6e 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -6628,7 +6628,9 @@ builtin_memset_gen_str (void *data, void *prevp,
       if (prev->mode == mode)
 	return prev->data;
 
-      return simplify_gen_subreg (mode, prev->data, prev->mode, 0);
+      target = simplify_gen_subreg (mode, prev->data, prev->mode, 0);
+      if (target != nullptr)
+	return target;
     }
 
   size = GET_MODE_SIZE (mode);
-- 
2.31.1

Reply via email to