This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/41339] Variables can occur multiple times in cfun->local_decls
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Feb 2017 08:56:12 +0000
- Subject: [Bug tree-optimization/41339] Variables can occur multiple times in cfun->local_decls
- Auto-submitted: auto-generated
- References: <bug-41339-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41339
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, as long as no verification was added (I don't spot any) we can't be sure
if the issue was resolved. A verification routine can be as simple as the
following (probably overkill for trunk this way, a few verifications like
after we build local decls in gimple-low.c and before RTL expansion in
cfgexpand.c is enough in the end).
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 245240)
+++ gcc/tree-cfg.c (working copy)
@@ -5093,6 +5121,24 @@ collect_subblocks (hash_set<tree> *block
}
}
+/* Verify the functions local_decls. */
+
+static bool
+verify_local_decls(struct function *fn)
+{
+ /* For the moment verify we don't have any duplicates, see PR41339. */
+ if (vec_safe_is_empty (fn->local_decls))
+ return false;
+ hash_set <tree> s;
+ for (unsigned i = 0; i < fn->local_decls->length (); ++i)
+ if (s.add ((*fn->local_decls)[i]))
+ {
+ error ("duplicate decls in local-decls");
+ return true;
+ }
+ return false;
+}
+
/* Verify the GIMPLE statements in the CFG of FN. */
DEBUG_FUNCTION void
@@ -5105,6 +5151,8 @@ verify_gimple_in_cfg (struct function *f
hash_set<void *> visited;
hash_set<gimple *> visited_stmts;
+ err |= verify_local_decls (fn);
+
/* Collect all BLOCKs referenced by the BLOCK tree of FN. */
hash_set<tree> blocks;
if (DECL_INITIAL (fn->decl))