Commit 3b5d135
committed
[AOT] Avoid call_extern() with incorrect argument count
Prior to this commit, if device initialization is required, the AOT
main function produced a `call_extern()` that included the device
context as input. This commit updates the AOT main function to
provide the device context only if the function being called accepts a
device context as input.
If an extra device context argument is included at the call site, the
C codegen would produce a function signature that includes the device
context for the caller's compilation unit, but a signature without the
device context for the callee's compilation unit. While this can
compile and run in some cases, it is undefined behavior for the
signature to vary between compilation units, and should be avoided.
This was initially discovered while debugging
apache#14985, in which changes to the
lowering flow resulted in the caller and callee being within the same
compilation unit.1 parent 3c23865 commit 3b5d135
1 file changed
+37
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
458 | 483 | | |
459 | 484 | | |
460 | 485 | | |
| |||
1007 | 1032 | | |
1008 | 1033 | | |
1009 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
1010 | 1037 | | |
1011 | 1038 | | |
1012 | 1039 | | |
| |||
1183 | 1210 | | |
1184 | 1211 | | |
1185 | 1212 | | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1186 | 1222 | | |
1187 | 1223 | | |
1188 | 1224 | | |
| |||
0 commit comments