Skip to content
Snippets Groups Projects
Commit b317dca0 authored by kelefth's avatar kelefth Committed by Philipp Tomsich
Browse files

avoid-store-forwarding: bail when an instruction may throw [PR117816]

Avoid-store-forwarding doesn't handle the case where an instruction in
the store-load sequence contains a REG_EH_REGION note, leading to the
insertion of instructions after it, while it should be the last
instruction in the basic block. This causes an ICE when compiling
using `-O -fnon-call-exceptions -favoid-store-forwarding
-fno-forward-propagate -finstrument-functions`.

This patch rejects the transformation when there are instructions in
the sequence that may throw an exeption.

	PR rtl-optimization/117816

gcc/ChangeLog:

	* avoid-store-forwarding.cc (store_forwarding_analyzer::avoid_store_forwarding):
	Reject the transformation when having instructions that may
	throw exceptions in the sequence.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr117816.c: New test.
parent ed210c69
No related branches found
No related tags found
No related merge requests found
...@@ -429,7 +429,7 @@ store_forwarding_analyzer::avoid_store_forwarding (basic_block bb) ...@@ -429,7 +429,7 @@ store_forwarding_analyzer::avoid_store_forwarding (basic_block bb)
rtx set = single_set (insn); rtx set = single_set (insn);
if (!set) if (!set || insn_could_throw_p (insn))
{ {
store_exprs.truncate (0); store_exprs.truncate (0);
continue; continue;
......
/* { dg-do compile } */
/* { dg-options "-O -fnon-call-exceptions -favoid-store-forwarding -fno-forward-propagate -finstrument-functions" } */
char *p;
int y;
long x;
void foo()
{
x /= *(int *)__builtin_memmove(&y, 4 + p, 3);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment