This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fwd: [PATCH] Prevent crash when expand movstr fail when movstr pattern is defined
- From: Kito Cheng <kito at 0xlab dot org>
- To: sandra at codesourcery dot com, aoliva at redhat dot com, rsandifo at linux dot vnet dot ibm dot com, gcc-patches at gcc dot gnu dot org, jakub at redhat dot com, Chung-Ju Wu <jasonwucj at gmail dot com>
- Date: Sat, 11 Jan 2014 00:48:09 +0800
- Subject: Fwd: [PATCH] Prevent crash when expand movstr fail when movstr pattern is defined
- Authentication-results: sourceware.org; auth=none
- References: <CA+yXCZDhJBuxcWHGr+TbYz-Py1YUgXq=WiZutJZLXqzh09Nduw at mail dot gmail dot com>
Hi,
expand_movstr is work fine when we don't define movstr pattern or
always expand it successfully, however it's will crash when if movstr
expand fail since expand_insn expect always expand successfully (it's
place a gcc_unreachable() when expand fail).
this patch use maybe_expand_insn instead of expand_insn, check it done
or not and just return NULL_RTX for generate a libcall if fail to
expand movstr.
2014-01-11 Kito Cheng <kito@0xlab.org>
* gcc/builtins.c (expand_movstr): Check movstr expand done or fail.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index e3c32a9..fca51a1 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3239,7 +3239,8 @@ expand_movstr (tree dest, tree src, rtx target, int endp)
create_output_operand (&ops[0], endp ? target : NULL_RTX, Pmode);
create_fixed_operand (&ops[1], dest_mem);
create_fixed_operand (&ops[2], src_mem);
- expand_insn (CODE_FOR_movstr, 3, ops);
+ if (!maybe_expand_insn (CODE_FOR_movstr, 3, ops))
+ return NULL_RTX;
if (endp && target != const0_rtx)
{