forked from OSchip/llvm-project
IR: Make stripDebugInfo robust against (invalid) empty basic blocks
Since stripDebugInfo runs before the verifier when reading IR, we can end up in a situation where we read some invalid IR but don't know its invalid yet. Before this patch we would crash in stripDebugInfo when given IR with a completely empty basic block, and after we get a nice error from the verifier instead. llvm-svn: 311202
This commit is contained in:
parent
a2faf7b60f
commit
b29bebe47b
|
@ -311,6 +311,9 @@ bool llvm::stripDebugInfo(Function &F) {
|
|||
}
|
||||
|
||||
auto *TermInst = BB.getTerminator();
|
||||
if (!TermInst)
|
||||
// This is invalid IR, but we may not have run the verifier yet
|
||||
continue;
|
||||
if (auto *LoopID = TermInst->getMetadata(LLVMContext::MD_loop)) {
|
||||
auto *NewLoopID = LoopIDsMap.lookup(LoopID);
|
||||
if (!NewLoopID)
|
||||
|
|
Loading…
Reference in New Issue