The continue statement in JumpThreadingPass::ProcessThreadableEdges() correctly identifies the case when a predecessor is an indirectbr or callbr and must not be threaded. Unfortunately the bookkeeping for the remaining edges was incorrect and there are cases where a conditional branch in BB may be incorrectly folded based on the flawed analysis above. This patch correctly prevents folding in these cases while not fully pessimizing other threading opportunities to the same BB.
Thanks to Matthias Liedtke for creating a simplified test-case and concrete failure example.
See PR40992 for debug analysis.