Deduplicate and canonicalize all constants. (#3611)

Rather than producing multiple constants with the same value, fold all
instances of a given constant to the same constant instruction.

A future PR will use this to replace the current type canonicalization
system.
This commit is contained in:
Richard Smith
2024-01-18 21:42:19 +00:00
committed by GitHub
parent 62db3e9ad0
commit 29c294880d
142 changed files with 1603 additions and 1185 deletions
+5 -1
View File
@@ -38,6 +38,10 @@ interface Class { }
// CHECK:STDOUT: --- fail_duplicate.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Class: type = class_type @Class [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.Interface = %Interface.decl.loc7, .Function = %Function, .Class = %Class.decl} [template]
// CHECK:STDOUT: %Interface.decl.loc7 = interface_decl @Interface, ()
@@ -45,7 +49,7 @@ interface Class { }
// CHECK:STDOUT: %Function: <function> = fn_decl @Function [template]
// CHECK:STDOUT: %.decl.loc27 = interface_decl @.1, ()
// CHECK:STDOUT: %Class.decl = class_decl @Class, ()
// CHECK:STDOUT: %Class: type = class_type @Class [template]
// CHECK:STDOUT: %Class: type = class_type @Class [template = constants.%Class]
// CHECK:STDOUT: %.decl.loc37 = interface_decl @.2, ()
// CHECK:STDOUT: }
// CHECK:STDOUT: