Commit e7a282b
[move-model] Track struct usage during build instead of lazy computation
Replace the expensive lazy computation in StructEnv::get_using_functions() which iterates over all modules and all functions with eager tracking during function body translation.
- Add using_functions field to StructEntry to accumulate usage during build
- In def_ana_fun, after translating function body, collect used structs via struct_usage() and update corresponding StructEntry
- Pass the collected using_functions from StructEntry to StructData during finalization
This eliminates the O(modules * functions) scan on every get_using_functions() call, making unused struct detection much more efficient.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent f6b3e09 commit e7a282b
File tree
2 files changed
+25
-3
lines changed- third_party/move/move-model/src/builder
2 files changed
+25
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
| |||
392 | 394 | | |
393 | 395 | | |
394 | 396 | | |
| 397 | + | |
395 | 398 | | |
396 | 399 | | |
397 | 400 | | |
| |||
Lines changed: 22 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
1490 | 1491 | | |
1491 | 1492 | | |
1492 | 1493 | | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
1493 | 1512 | | |
1494 | 1513 | | |
1495 | 1514 | | |
| |||
3624 | 3643 | | |
3625 | 3644 | | |
3626 | 3645 | | |
3627 | | - | |
| 3646 | + | |
3628 | 3647 | | |
3629 | 3648 | | |
3630 | 3649 | | |
| |||
0 commit comments