mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +01:00
Add GlobalInit to blocks to emit initialization instructions for globals (#3687)
`GlobalInit` block is now static block within a `SemIR` which will be used to emit initialization instructions for variables in the `Package` scope. inst_block_stack now has additional methods to handle `GlobalInit` block separately, this block can be popped without being finalized allowing to accumulate between all instances of variables. At the end of the `check` phase, if this block is not empty , the function `__global_init` will be added with this block being inserted into it. This block is pushed to `inst_block_scope` at the end `BindName`, allowing instruction to be emitted into it, then popped at the semicolon (VariableDecl). This significantly changes the `SemIR` output, that's why this commit updates a lot of the test cases.
This commit is contained in:
@@ -43,7 +43,7 @@ class C {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: %.loc17: i32 = block_arg <unexpected instblockref block5>
|
||||
// CHECK:STDOUT: %.loc17: i32 = block_arg <unexpected instblockref block6>
|
||||
// CHECK:STDOUT: %x: i32 = bind_name x, %.loc17
|
||||
// CHECK:STDOUT: %C.decl = class_decl @C, ()
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user