llvm-project
63e60a28 - [BOLT] Fix strict mode bug in removal of block referenced by JT (#211940)

Commit
57 days ago
[BOLT] Fix strict mode bug in removal of block referenced by JT (#211940) Summary: BOLT can create a jump table object from a PC-relative operand reference (e.g. leaq JT(%rip)) whenever the referenced memory looks like a PIC jump table -- see BinaryContext::handleAddressRef. This is independent of whether BOLT recognizes the indirect jump dispatch itself. The jump table annotation is only attached to the jmp instruction later, in BinaryFunction::analyzeIndirectBranch, and only when the target-specific analyzeIndirectBranch matcher recognizes the dispatch pattern. If the matcher does not recognize the pattern, the annotation is never attached to the jmp, even though the jump table object and its entries exist and reference basic blocks in the function. In strict mode BOLT still fully processes such a function: it stays simple, the block is marked as having unknown control flow, and the jump table object is kept intact. Because the terminator carries no jump table annotation, BinaryBasicBlock::hasJumpTable() returns false for it. Later passes then transform the function normally: remove-nops can empty a jump table target block that consists only of nops, and NormalizeCFG then redirects the block's predecessor and deletes the empty block - it does not recognize the block as a jump table target, since the predecessor's hasJumpTable() is false. The jump table object still references the deleted block by label, which produces an "Undefined temporary symbol" error and fails emission. Fix NormalizeCFG so it does not redirect/remove a block whose predecessor ends in an indirect branch, not only one flagged by hasJumpTable().
Author
Parents
Loading