Commit e41cac3
Don't push a poison aggregate onto the sret rooting worklist
`needsReRooting` walks every value stored into an sret argument to check each
tracked pointer is also parked in the returnRoots array. Walking back through an
insertvalue chain, the branch for an insert of an untracked field pushed the
aggregate operand unconditionally:
CountTrackedPointers tracked(IVI->getInsertedValueOperand()->getType());
if (tracked.count == 0) { storedValues.push_back(IVI->getAggregateOperand()); continue; }
When that operand is the poison the chain was built from, the bare poison lands
on the worklist. The struct handling below then looks for an extractvalue
covering poison's tracked fields, finds none, and reports
failed to find extracted pointer for %tape poison at index 1
before falling through to the pointer-shaped handling, whose assert(0) fires on
any non-pointer value. Julia hits this whenever a nested sub-tape survives SROA
as a whole-aggregate store and its first field is untracked -- reverse mode over
PEPSKit's CTMRG aborts the process this way, since the shipped Enzyme_jll
RelWithDebInfo build leaves assertions live.
A poison, undef, or zeroinitializer aggregate has no live pointer in any field,
so it needs no root regardless of which field the insertvalue overwrites. Hoist
the trivial-base test above both branches and drop such a base, which is the
reasoning the tracked branch three lines down already relies on. In the Julia
case the tracked pointers are separately stored into the returnRoots, so the
walk then completes and the pass correctly concludes it has no work to do.
Also un-shadow `legal` in the struct handling. The inner declaration meant the
coverage failure set a variable nobody read and fell into that same assert;
report it through CustomErrorHandler like the pointer path does and reroot
conservatively. This is not a behaviour change for NDEBUG builds, which already
fell through to exactly that handler.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 2593327 commit e41cac3
2 files changed
Lines changed: 56 additions & 6 deletions
File tree
- enzyme
- Enzyme
- test/Enzyme/JuliaCallingConvention
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
226 | 233 | | |
227 | 234 | | |
228 | 235 | | |
| 236 | + | |
| 237 | + | |
229 | 238 | | |
230 | 239 | | |
231 | 240 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
243 | | - | |
| 250 | + | |
244 | 251 | | |
245 | 252 | | |
246 | 253 | | |
| |||
336 | 343 | | |
337 | 344 | | |
338 | 345 | | |
339 | | - | |
| 346 | + | |
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
343 | | - | |
| 350 | + | |
344 | 351 | | |
345 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
346 | 367 | | |
347 | 368 | | |
348 | 369 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments