0002-xtensa-fix-PR-target-91880.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 7c11710230921246156aecc20eb4b6ccaeaaa473 Mon Sep 17 00:00:00 2001
  2. From: Max Filippov <jcmvbkbc@gmail.com>
  3. Date: Tue, 24 Sep 2019 04:15:17 -0700
  4. Subject: [PATCH] xtensa: fix PR target/91880
  5. Xtensa hwloop_optimize segfaults when zero overhead loop is about to be
  6. inserted as the first instruction of the function.
  7. Insert zero overhead loop instruction into new basic block before the
  8. loop when basic block that precedes the loop is empty.
  9. 2019-09-26 Max Filippov <jcmvbkbc@gmail.com>
  10. gcc/
  11. * config/xtensa/xtensa.c (hwloop_optimize): Insert zero overhead
  12. loop instruction into new basic block before the loop when basic
  13. block that precedes the loop is empty.
  14. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  15. ---
  16. Backported from: r276166
  17. gcc/config/xtensa/xtensa.c | 5 ++--
  18. 1 file changed, 3 insertions(+), 2 deletions(-)
  19. diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
  20. index ee5612441e25..2527468d57db 100644
  21. --- a/gcc/config/xtensa/xtensa.c
  22. +++ b/gcc/config/xtensa/xtensa.c
  23. @@ -4232,7 +4232,9 @@ hwloop_optimize (hwloop_info loop)
  24. seq = get_insns ();
  25. - if (!single_succ_p (entry_bb) || vec_safe_length (loop->incoming) > 1)
  26. + entry_after = BB_END (entry_bb);
  27. + if (!single_succ_p (entry_bb) || vec_safe_length (loop->incoming) > 1
  28. + || !entry_after)
  29. {
  30. basic_block new_bb;
  31. edge e;
  32. @@ -4253,7 +4255,6 @@ hwloop_optimize (hwloop_info loop)
  33. }
  34. else
  35. {
  36. - entry_after = BB_END (entry_bb);
  37. while (DEBUG_INSN_P (entry_after)
  38. || (NOTE_P (entry_after)
  39. && NOTE_KIND (entry_after) != NOTE_INSN_BASIC_BLOCK))
  40. --
  41. 2.11.0