Commit 06d432c
authored
lowering: Canonicalize to builtins for global assignment (JuliaLang#56713)
This adjusts lowering to emit `setglobal!` for assignment to globals,
thus making the `=` expr head used only for slots in `CodeInfo` and
entirely absent in `IRCode`. The primary reason for this is just to
reduce the number of special cases that compiler passes have to reason
about. In IRCode, `=` was already essentially equivalent to
`setglobal!`, so there's no good reason not to canonicalize.
Finally, the `=` syntax form for globals already gets recognized
specially to insert `convert` calls to their declared binding type, so
this doesn't impose any additional requirements on lowering to
distinguish local from global assignments. In general, I'd also like to
separate syntax and intermediate forms as much as possible where their
semantics differ, which this accomplises by just using the builtin.
This change is mostly semantically invisible, except that spliced-in
GlobalRefs now declare their binding because they are indistinguishable
from ordinary assignments at the stage where I inserted the lowering. If
we want to, we can preserve the difference, but it'd be a bit more
annoying for not much benefit, because:
1. The spliced in version was only recently made to work anyway, and
2. The semantics of when exactly bindings are declared is still messy on
master anyway and will get tweaked shortly in further binding partitions
work.1 parent ed0636f commit 06d432c
File tree
5 files changed
+5
-38
lines changed- src
- ssair
- test
5 files changed
+5
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4050 | 4050 | | |
4051 | 4051 | | |
4052 | 4052 | | |
4053 | | - | |
4054 | | - | |
4055 | | - | |
4056 | | - | |
4057 | | - | |
4058 | | - | |
4059 | | - | |
| 4053 | + | |
4060 | 4054 | | |
4061 | 4055 | | |
4062 | 4056 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1408 | 1408 | | |
1409 | 1409 | | |
1410 | 1410 | | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
| 1411 | + | |
1421 | 1412 | | |
1422 | 1413 | | |
1423 | 1414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | 645 | | |
653 | 646 | | |
654 | 647 | | |
| |||
981 | 974 | | |
982 | 975 | | |
983 | 976 | | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | 977 | | |
990 | 978 | | |
991 | 979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 366 | + | |
| 367 | + | |
374 | 368 | | |
375 | 369 | | |
376 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2111 | 2111 | | |
2112 | 2112 | | |
2113 | 2113 | | |
2114 | | - | |
| 2114 | + | |
2115 | 2115 | | |
2116 | 2116 | | |
2117 | 2117 | | |
| |||
0 commit comments