Commit 6fa7d42
Drop unreachable blocks after inlining
Summary:
The HIR inliner could crash when inlining a callee that has no reachable
`return`, for example a `while True:` loop whose only exit is an exception.
`HIRBuilder::inlineHIR` builds the callee CFG but, unlike the normal `buildHIR`
path, does not run `removeUnreachableBlocks`. When the callee has no reachable
return, the merged exit block (and the surrounding return-value
`Assign`/`Branch` blocks produced by `inlineFunctionCall`) end up with no
predecessors and are left in the caller's CFG. `InlineFunctionCalls::Run` then
ran `CopyPropagation` and `CleanCFG` over those stale blocks; `CleanCFG` ->
`PhiElimination` -> `chaseAssignOperand` dereferenced instructions that had
already been freed during inlining, segfaulting inside
`InlineFunctionCalls::Run`.
Fixes #120.
Reviewed By: mpage
Differential Revision: D110056992
fbshipit-source-id: a0c450ad7c414d092f167bec2e1de4ea039519f41 parent 194b430 commit 6fa7d42
2 files changed
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
611 | 612 | | |
612 | 613 | | |
613 | 614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
193 | 261 | | |
194 | 262 | | |
195 | 263 | | |
| |||
365 | 433 | | |
366 | 434 | | |
367 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
368 | 457 | | |
369 | 458 | | |
370 | 459 | | |
| |||
0 commit comments