Commit e138826
Tyler Lanphear
[IR] Don't skip
`getFirstNonPHIOrDbgOrAlloca()`
`BasicBlock::getFirstNonPHIOrDbgOrAlloca()` is supposed to yield the
first instruction in the block which is not a PHI or dbg or alloca
instruction. To that effect, it also skips an EHPad instruction which
might be present after any PHIs. Normally, the latter is fine, but it
has an unexpected interaction with `catchswitch` blocks:
```
bb:
; optional PHIs
%0 = catchswitch within none [label %catch] unwind to caller
```
If we skip over the `catchswitch` instruction in the previous block,
we'll return the end iterator, despite `catchswitch` not being a PHI or
dbg or alloca instruction.
This patch amends the logic to not skip an EHPad instruction which is
also a terminator. This means that calling
`getFirstNonPHIOrDbgOrAlloca()` on a non-empty block with a terminator
(such as the above) will always yield a valid instruction iterator. This
appears to be the expected behavior anyways, as most usages of this
method do not check that the returned iterator is `end()`.
Closes #136048.catchswitch instructions when calling1 parent 6727d58 commit e138826
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| |||
0 commit comments