[llvm] [IR] Don't skip `catchswitch` when calling `BB::getFirstNonPHIOrDbgOrAlloca()` (PR #136056)

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 17:23:27 PDT 2025


majnemer wrote:

Interesting bug! This is exposing a conflict between `getFirstNonPHIOrDbgOrAlloca` and one of its uses cases: scanning "interesting" instructions in a basic block.

However changing this is also in conflict with other use cases:
- Finding an insertion point where an instruction could go with a special case for the entry block wrt `AllocaInst`
- Per its documentation: "Returns an iterator to the first instruction in this block that is not a PHINode, a debug intrinsic, a static alloca or any pseudo operation."

`catchswitch` is definitely a pseudo operation.

I would not recommend changing this functions behavior to deviate from the documentation for two reasons:
- Perhaps there is code which uses the return result of `end()` to indicate that they should not try to do something with this BB.
- Having `getFirstInsertionPt` behave differently from `getFirstNonPHIOrDbgOrAlloca` in this way is surprising.

IMO, a cleaner fix would be to change `CheckForNonVecCallsInSameBlock` so that it took iterators instead of `Instruction*`. Have you considered something along those lines?

https://github.com/llvm/llvm-project/pull/136056


More information about the llvm-commits mailing list