Commit 417ff45
Remove the
Summary:
We must have the same stack layout (which registers are in which stack slots)
at control flow merge points to correctly translate between CPython's stack-based
bytecode and our register-based IR. Preserving this invariant was previously
split across two classes: `TempAllocator` and `BlockCanonicalizer`. `TempAllocator`
held the canonical stack layout in its `_cache` member and provided methods (`AllocateStack`
and `GetOrAllocateStack`) for manipulating the layout. `BlockCanonicalizer` inserted
register moves at block exit to put the stack into canonical form.
It's unsafe for a register that occupies a canonical stack slot to alias a local or a cell:
a register move might inadvertently overwrite the the aliased local/cell. `TempAllocator` provided
`AllocateNonStack` as a means of allocating registers that would never be used in stack slots.
However, this is a foot-gun: it forces callers to know when to choose between `AllocateStack`
and `AllocateNonStack`.
This diff eliminates the foot-gun while preserving the function-wide canonical stack
layout:
- The layout now lives on its consumer, `BlockCanonicalizer`. These registers are fully
disjoint from those allocated by the rest of `HIRBuilder`, making them safe to overwrite.
- `BlockCanonicalizer` is now a member of `HIRBuilder` and is reused across all
blocks, preserving the per function canonical layout.
- `TempAllocator` is removed, elminating the foot-gun.
Reviewed By: alexmalyshev
Differential Revision: D109868165
fbshipit-source-id: a35ac66b7f277f8e8a07827b69dd521f4fd628c4TempAllocator from HIRBuilder
1 parent 6f82247 commit 417ff45
13 files changed
Lines changed: 2138 additions & 2161 deletions
File tree
- cinderx
- Jit/hir
- RuntimeTests
- hir_tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | 26 | | |
47 | 27 | | |
48 | 28 | | |
| |||
53 | 33 | | |
54 | 34 | | |
55 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
56 | 40 | | |
57 | 41 | | |
58 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
59 | 45 | | |
60 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
61 | 52 | | |
62 | 53 | | |
63 | 54 | | |
64 | 55 | | |
65 | 56 | | |
66 | 57 | | |
67 | | - | |
68 | 58 | | |
69 | 59 | | |
70 | 60 | | |
| 61 | + | |
| 62 | + | |
71 | 63 | | |
72 | 64 | | |
73 | 65 | | |
| |||
541 | 533 | | |
542 | 534 | | |
543 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
544 | 539 | | |
545 | 540 | | |
546 | 541 | | |
547 | 542 | | |
548 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
| 44 | + | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| |||
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
63 | | - | |
| 61 | + | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
| |||
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | | - | |
| 81 | + | |
84 | 82 | | |
85 | 83 | | |
86 | | - | |
87 | | - | |
| 84 | + | |
| 85 | + | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
98 | 96 | | |
99 | 97 | | |
100 | 98 | | |
101 | | - | |
102 | | - | |
| 99 | + | |
103 | 100 | | |
104 | 101 | | |
105 | 102 | | |
| |||
0 commit comments