mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 22:17:23 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user