mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:51:07 +01:00
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:
@@ -61,10 +61,6 @@ fn Main() {
|
||||
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %.3: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: %.6: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -97,18 +93,18 @@ fn Main() {
|
||||
// CHECK:STDOUT: %.loc18_7: init () = call %Run0.ref.loc18(<invalid>)
|
||||
// CHECK:STDOUT: %Run0.ref.loc25: <function> = name_ref Run0, file.%Run0 [template = file.%Run0]
|
||||
// CHECK:STDOUT: %.loc25_8: i32 = int_literal 0 [template = constants.%.3]
|
||||
// CHECK:STDOUT: %.loc25_11: i32 = int_literal 1 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc25_11: i32 = int_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc25_7: init () = call %Run0.ref.loc25(<invalid>)
|
||||
// CHECK:STDOUT: %Run1.ref.loc33: <function> = name_ref Run1, file.%Run1 [template = file.%Run1]
|
||||
// CHECK:STDOUT: %.loc33: init () = call %Run1.ref.loc33(<invalid>)
|
||||
// CHECK:STDOUT: %Run1.ref.loc40: <function> = name_ref Run1, file.%Run1 [template = file.%Run1]
|
||||
// CHECK:STDOUT: %.loc40_8: i32 = int_literal 0 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc40_11: i32 = int_literal 1 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc40_8: i32 = int_literal 0 [template = constants.%.3]
|
||||
// CHECK:STDOUT: %.loc40_11: i32 = int_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc40_7: init () = call %Run1.ref.loc40(<invalid>)
|
||||
// CHECK:STDOUT: %Run2.ref.loc48: <function> = name_ref Run2, file.%Run2 [template = file.%Run2]
|
||||
// CHECK:STDOUT: %.loc48: init () = call %Run2.ref.loc48(<invalid>)
|
||||
// CHECK:STDOUT: %Run2.ref.loc55: <function> = name_ref Run2, file.%Run2 [template = file.%Run2]
|
||||
// CHECK:STDOUT: %.loc55_8: i32 = int_literal 0 [template = constants.%.7]
|
||||
// CHECK:STDOUT: %.loc55_8: i32 = int_literal 0 [template = constants.%.3]
|
||||
// CHECK:STDOUT: %.loc55_7: init () = call %Run2.ref.loc55(<invalid>)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -16,7 +16,6 @@ fn Main() {
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.2: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -36,7 +35,7 @@ fn Main() {
|
||||
// CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7)
|
||||
// CHECK:STDOUT: %Foo.ref.loc11: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
|
||||
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.3]
|
||||
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref.loc11(%.loc11_7)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -17,8 +17,6 @@ fn Main() {
|
||||
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.2: i32 = int_literal 2 [template]
|
||||
// CHECK:STDOUT: %.3: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -39,8 +37,8 @@ fn Main() {
|
||||
// CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc10_6: init () = call %Foo.ref.loc10(%.loc10_7, %.loc10_10)
|
||||
// CHECK:STDOUT: %Foo.ref.loc11: <function> = name_ref Foo, file.%Foo [template = file.%Foo]
|
||||
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc11_6: init () = call %Foo.ref.loc11(%.loc11_7, %.loc11_10)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -14,6 +14,10 @@ fn F(T:! type, U:! type) {
|
||||
|
||||
// CHECK:STDOUT: --- fail_type_param_mismatch.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: type = ptr_type T [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace package, {.F = %F} [template]
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
|
||||
@@ -22,7 +26,7 @@ fn F(T:! type, U:! type) {
|
||||
// CHECK:STDOUT: fn @F(%T: type, %U: type) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T]
|
||||
// CHECK:STDOUT: %.loc8: type = ptr_type T [template]
|
||||
// CHECK:STDOUT: %.loc8: type = ptr_type T [template = constants.%.1]
|
||||
// CHECK:STDOUT: %p.var: ref T* = var p
|
||||
// CHECK:STDOUT: %p: ref T* = bind_name p, %p.var
|
||||
// CHECK:STDOUT: %U.ref: type = name_ref U, %U [symbolic = %U]
|
||||
|
||||
@@ -11,6 +11,10 @@ fn F(T:! type) {
|
||||
|
||||
// CHECK:STDOUT: --- type_param.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: type = ptr_type T [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace package, {.F = %F} [template]
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
|
||||
@@ -19,7 +23,7 @@ fn F(T:! type) {
|
||||
// CHECK:STDOUT: fn @F(%T: type) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %T.ref.loc8: type = name_ref T, %T [symbolic = %T]
|
||||
// CHECK:STDOUT: %.loc8: type = ptr_type T [template]
|
||||
// CHECK:STDOUT: %.loc8: type = ptr_type T [template = constants.%.1]
|
||||
// CHECK:STDOUT: %p.var: ref T* = var p
|
||||
// CHECK:STDOUT: %p: ref T* = bind_name p, %p.var
|
||||
// CHECK:STDOUT: %T.ref.loc9: type = name_ref T, %T [symbolic = %T]
|
||||
|
||||
Reference in New Issue
Block a user