Commit c05b68f
authored
Don't inline generated functions if we can't invoke their generator (JuliaLang#59018)
This PR disables inlining (via an outer `src_inlining_policy` method)
for method instances obtained from `@generated` methods if we cannot
invoke their generator during compilation, deferring their execution to
runtime via dynamic dispatch.
Generated functions may be called with arguments that are not fully
inferrable, yet we might inline them. The lack of concretely inferred
argument types can cause the generator function to not be invoked
`may_invoke_generator(mi) === false`, which causes its fallback
definition to be executed when one is available to expand its body (the
`else` branch of a `if @generated` construct, if present). However,
fallback definitions were intended to enable more accurate type
inference, but not to be actually used for execution; they will
typically be slower, and in this case, it is best to defer the
generation of the method body to runtime, where the generator can be
invoked with concrete argument types.
Implements
JuliaLang#59013 (comment),
fixing JuliaLang#58915.1 parent c2fd42e commit c05b68f
File tree
5 files changed
+62
-14
lines changed- Compiler
- src
- ssair
- test
5 files changed
+62
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1245 | 1245 | | |
1246 | 1246 | | |
1247 | 1247 | | |
1248 | | - | |
| 1248 | + | |
1249 | 1249 | | |
1250 | 1250 | | |
1251 | 1251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
868 | | - | |
| 868 | + | |
869 | 869 | | |
870 | 870 | | |
871 | 871 | | |
| |||
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
900 | | - | |
| 900 | + | |
901 | 901 | | |
902 | 902 | | |
903 | 903 | | |
| |||
1448 | 1448 | | |
1449 | 1449 | | |
1450 | 1450 | | |
1451 | | - | |
| 1451 | + | |
1452 | 1452 | | |
1453 | 1453 | | |
1454 | 1454 | | |
| |||
1458 | 1458 | | |
1459 | 1459 | | |
1460 | 1460 | | |
1461 | | - | |
| 1461 | + | |
1462 | 1462 | | |
1463 | 1463 | | |
1464 | 1464 | | |
| |||
1602 | 1602 | | |
1603 | 1603 | | |
1604 | 1604 | | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
| 1605 | + | |
| 1606 | + | |
1609 | 1607 | | |
1610 | 1608 | | |
1611 | 1609 | | |
| |||
1625 | 1623 | | |
1626 | 1624 | | |
1627 | 1625 | | |
1628 | | - | |
| 1626 | + | |
| 1627 | + | |
1629 | 1628 | | |
1630 | 1629 | | |
1631 | 1630 | | |
1632 | 1631 | | |
1633 | | - | |
1634 | | - | |
| 1632 | + | |
1635 | 1633 | | |
1636 | 1634 | | |
1637 | 1635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1532 | 1532 | | |
1533 | 1533 | | |
1534 | 1534 | | |
1535 | | - | |
| 1535 | + | |
1536 | 1536 | | |
1537 | 1537 | | |
1538 | 1538 | | |
| |||
1545 | 1545 | | |
1546 | 1546 | | |
1547 | 1547 | | |
1548 | | - | |
| 1548 | + | |
1549 | 1549 | | |
1550 | 1550 | | |
1551 | 1551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2314 | 2314 | | |
2315 | 2315 | | |
2316 | 2316 | | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
2317 | 2356 | | |
0 commit comments