Implement canonicalization of Value and Element (#3024)

See arena.h for discussion of what canonicalization means in this
context. This is primarily intended to support implementing a memo table
of template instantiations to resolve #2951, but could be useful for
other purposes as well.

Additional changes:
- Pass `VTable` constructor parameters by pointer, to avoid the need to
define `operator==` and `hash_value` for it.
- Clean up the recurring pattern of allocating identical `NamedElement`s
on the stack and heap. Instead we always allocate it on the heap and
pass it by pointer.
- Add `Print()` and `Dump()` to `Bindings` as a debugging convenience.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2023-08-03 16:05:59 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins Richard Smith
parent 2c4fff25a8
commit c93a0e5e42
18 changed files with 614 additions and 113 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ struct NestedValueVisitor {
// which is not "within" this value, so we shouldn't visit it.
return true;
}
auto Visit(const VTable&) -> bool { return true; }
auto Visit(const VTable*) -> bool { return true; }
llvm::function_ref<bool(const Value*)> callback;
};