public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8086] gccrs: borrowck: Dump: handle infinite loops
@ 2024-01-16 18:17 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4c65919e19ca670b200718c0c37d24a9111fe4b9
commit r14-8086-g4c65919e19ca670b200718c0c37d24a9111fe4b9
Author: Jakub Dupak <dev@jakubdupak.com>
Date: Thu Oct 19 11:04:29 2023 +0200
gccrs: borrowck: Dump: handle infinite loops
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-dump.cc (simplify_cfg): Detech infinite loops.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Diff:
---
gcc/rust/checks/errors/borrowck/rust-bir-dump.cc | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index ba530983dad..66870ddeb56 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -1,5 +1,6 @@
#include <numeric>
#include "rust-bir-dump.h"
+#include "rust-diagnostics.h"
namespace Rust {
namespace BIR {
@@ -76,7 +77,21 @@ simplify_cfg (Function &func, std::vector<BasicBlockId> &bb_fold_map)
const BasicBlock &bb = func.basic_blocks[bb_fold_map[i]];
if (bb.statements.empty () && bb.is_goto_terminated ())
{
- bb_fold_map[i] = bb.successors.at (0);
+ auto dst = bb.successors.at (0);
+ if (bb_fold_map[dst] != dst)
+ {
+ rust_error_at (
+ UNKNOWN_LOCATION,
+ "BIR DUMP: Cannot fold CFG, because it contains an "
+ "infinite loop with no executable statements.");
+ rust_inform (UNKNOWN_LOCATION,
+ "Continuing with an unfolded CFG.");
+ // Reverting the fold map to the original state.
+ std::iota (bb_fold_map.begin (), bb_fold_map.end (), 0);
+ stabilized = true;
+ break;
+ }
+ bb_fold_map[i] = dst;
stabilized = false;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:17 [gcc r14-8086] gccrs: borrowck: Dump: handle infinite loops Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).