aboutsummaryrefslogtreecommitdiff
path: root/gcc/pointer-query.h
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-10-31 20:54:29 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-11-02 22:16:13 +1100
commit4a99443c5dd9a235022652ba0fb143c6370ea99d (patch)
tree857f0912fa74ece4109b6115a709058aaf169ae6 /gcc/pointer-query.h
parent6a2e8913df605e62f20833a6e688ea1950147edc (diff)
downloadgcc-4a99443c5dd9a235022652ba0fb143c6370ea99d.zip
gcc-4a99443c5dd9a235022652ba0fb143c6370ea99d.tar.gz
gcc-4a99443c5dd9a235022652ba0fb143c6370ea99d.tar.bz2
c++/modules: Fix recursive dependencies [PR116317]
In cases like the linked PR we sometimes get mutually recursive dependencies that both rely on the other to have been streamed as part of their merge key information. In the linked PR, this causes an ICE. The root cause is that 'sort_cluster' is not correctly ordering the dependencies; both the element_t specialisation and the reverse_adaptor::first function decl depend on each other, but by streaming element_t first it ends up trying to stream itself recursively as part of calculating its own merge key, which apart from the checking ICE will also cause issues on stream-in, as the merge key will not properly stream. There is a comment already in 'sort_cluster' describing this issue, but it says: Finding the single cluster entry dep is very tricky and expensive. Let's just not do that. It's harmless in this case anyway. However in this case it was not harmless: it's just somewhat luck that the sorting happened to work for the existing cases in the testsuite. This patch solves the issue by noting any declarations that rely on deps first seen within their own merge key. This declaration gets marked as an "entry" dep; any of these deps that end up recursively referring back to that entry dep as part of their own merge key do not. Then within sort_cluster we can ensure that the entry dep is written to be streamed first of its cluster; this will ensure that any other deps are just emitted as back-references, and the mergeable dep itself will structurally decompose. PR c++/116317 gcc/cp/ChangeLog: * module.cc (depset::DB_MAYBE_RECURSIVE_BIT): New flag. (depset::DB_ENTRY_BIT): New flag. (depset::is_maybe_recursive): New accessor. (depset::is_entry): New accessor. (depset::hash::writing_merge_key): New field. (trees_out::decl_value): Inform dep_hash while we're writing the merge key information for a decl. (depset::hash::add_dependency): Find recursive deps and mark the entry point. (sort_cluster): Ensure that the entry dep is streamed first. gcc/testsuite/ChangeLog: * g++.dg/modules/late-ret-4_a.H: New test. * g++.dg/modules/late-ret-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/pointer-query.h')
0 files changed, 0 insertions, 0 deletions