[llvm] [BranchFolder] Prevent nested salvage in empty BB chains with pseudo probes (PR #206092)
Jinjie Huang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 06:08:08 PDT 2026
Jinjie-Huang wrote:
@arsenm Thanks for the review!
> How can a block contain a pseudo-probe if it's empty?
By "empty" I am referring to the condition checked by [IsEmptyBlock()](https://github.com/llvm/llvm-project/blob/llvmorg-23-init/llvm/lib/CodeGen/BranchFolding.cpp#L1265). Under the hood, it calls MBB->[getFirstNonDebugInstr](https://github.com/llvm/llvm-project/blob/llvmorg-23-init/llvm/lib/CodeGen/MachineBasicBlock.cpp#L265)(true /* SkipPseudoOp */), which linearly scans the BB to verify it contains only DBG and pseudo instructions. So at the code level, "empty" means the MBB contains no real machine instructions (even though it is not strictly empty() in the physical sense).
By the way, do you think it's better to try fixing this by optimizing [`getFirstTerminator()`](https://github.com/llvm/llvm-project/blob/llvmorg-23-init/llvm/lib/CodeGen/MachineBasicBlock.cpp#L242), like the `getFirstTerminatorFast()` approach I showed above?
https://github.com/llvm/llvm-project/pull/206092
More information about the llvm-commits
mailing list