From 52613396a6837e5c8b8334821022cad70fe8e917 Mon Sep 17 00:00:00 2001 From: HaohaiWen Date: Thu, 11 Jan 2024 22:10:56 +0800 Subject: [PATCH] [InstrRef] Add debug hint for not reachable blocks from entry (#77725) Those not reachable blocks was not analyzed by LiveDebugValues and may raise out of bound access to VarLocs as case in #77441. --- llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index 9037f752dc4f..cfc8c28b99e5 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -2403,8 +2403,15 @@ bool InstrRefBasedLDV::mlocJoin( llvm::sort(BlockOrders, Cmp); // Skip entry block. - if (BlockOrders.size() == 0) + if (BlockOrders.size() == 0) { + // FIXME: We don't use assert here to prevent instr-ref-unreachable.mir + // failing. + LLVM_DEBUG(if (!MBB.isEntryBlock()) dbgs() + << "Found not reachable block " << MBB.getFullName() + << " from entry which may lead out of " + "bound access to VarLocs\n"); return false; + } // Step through all machine locations, look at each predecessor and test // whether we can eliminate redundant PHIs.