diff options
author | Adrian Prantl <aprantl@apple.com> | 2022-08-02 10:27:45 -0700 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2022-08-03 13:05:05 -0700 |
commit | 905f2d1ecbcb5c390fbbbc5218be76a654b55cbb (patch) | |
tree | 0b23469f27c74914d4f393d76b0ce304d6d6bd65 /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | |
parent | c5ccb78ade8136134e0ca9dde64de97f913f0f8c (diff) | |
download | llvm-905f2d1ecbcb5c390fbbbc5218be76a654b55cbb.zip llvm-905f2d1ecbcb5c390fbbbc5218be76a654b55cbb.tar.gz llvm-905f2d1ecbcb5c390fbbbc5218be76a654b55cbb.tar.bz2 |
Fix LDV InstrRefBasedImpl to not crash when encountering unreachable MBBs.
The testcase was delta-reduced from an LTO build with sanitizer
coverage and the MIR tail duplication pass caused a machine basic
block to become unreachable in MIR. This caused the MBB to be invisible
to the reverse post-order traversal used to initialize the MBB <->
RPONumber lookup tables.
rdar://97226240
Differential Revision: https://reviews.llvm.org/D130999
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 191596d..db4ab3c 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -2933,12 +2933,17 @@ void InstrRefBasedLDV::initialSetup(MachineFunction &MF) { // Compute mappings of block <=> RPO order. ReversePostOrderTraversal<MachineFunction *> RPOT(&MF); unsigned int RPONumber = 0; - for (MachineBasicBlock *MBB : RPOT) { + auto processMBB = [&](MachineBasicBlock *MBB) { OrderToBB[RPONumber] = MBB; BBToOrder[MBB] = RPONumber; BBNumToRPO[MBB->getNumber()] = RPONumber; ++RPONumber; - } + }; + for (MachineBasicBlock *MBB : RPOT) + processMBB(MBB); + for (MachineBasicBlock &MBB : MF) + if (BBToOrder.find(&MBB) == BBToOrder.end()) + processMBB(&MBB); // Order value substitutions by their "source" operand pair, for quick lookup. llvm::sort(MF.DebugValueSubstitutions); |