OSDN Git Service

CodeGen: Check for a terminator in llvm::getFuncletMembership
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 11 Aug 2016 15:29:02 +0000 (15:29 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 11 Aug 2016 15:29:02 +0000 (15:29 +0000)
Check for an end iterator from MachineBasicBlock::getFirstTerminator in
llvm::getFuncletMembership.  If this is turned into an assertion, it
fires in 48 X86 testcases (for example,
CodeGen/X86/regalloc-spill-at-ehpad.ll).

Since this is likely a latent bug (shouldn't all basic blocks end with a
terminator?) I've filed PR28938.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Analysis.cpp

index d690734..9fb29b8 100644 (file)
@@ -694,6 +694,11 @@ llvm::getFuncletMembership(const MachineFunction &MF) {
     }
 
     MachineBasicBlock::const_iterator MBBI = MBB.getFirstTerminator();
+
+    // FIXME: Should this be an assertion?  It fires all over in X86.
+    if (MBBI == MBB.end())
+      continue;
+
     // CatchPads are not funclets for SEH so do not consider CatchRet to
     // transfer control to another funclet.
     if (MBBI->getOpcode() != TII->getCatchReturnOpcode())