Skip to content

Commit c377ddd

Browse files
committed
[CodeGen][DebugValues] Fix unhandled error condition in VarLoc
When assert() are disabled, this function can return corrupt data.
1 parent 4c43648 commit c377ddd

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -997,13 +997,6 @@ class VarLocBasedLDV : public LDVImpl {
997997
return *VLS;
998998
}
999999

1000-
const VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB,
1001-
const VarLocInMBB &Locs) const {
1002-
auto It = Locs.find(MBB);
1003-
assert(It != Locs.end() && "MBB not in map");
1004-
return *It->second;
1005-
}
1006-
10071000
/// Tests whether this instruction is a spill to a stack location.
10081001
bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF);
10091002

@@ -1284,9 +1277,10 @@ void VarLocBasedLDV::printVarLocInMBB(const MachineFunction &MF,
12841277
raw_ostream &Out) const {
12851278
Out << '\n' << msg << '\n';
12861279
for (const MachineBasicBlock &BB : MF) {
1287-
if (!V.count(&BB))
1280+
auto It = V.find(&BB);
1281+
if (It == V.end())
12881282
continue;
1289-
const VarLocSet &L = getVarLocsInMBB(&BB, V);
1283+
const VarLocSet &L = *It->second;
12901284
if (L.empty())
12911285
continue;
12921286
SmallVector<VarLoc, 32> VarLocs;

0 commit comments

Comments
 (0)