llvm-objdump: Skip branches that leave the current function.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 22 Jul 2011 18:35:09 +0000 (18:35 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 22 Jul 2011 18:35:09 +0000 (18:35 +0000)
In "normal" code these only happen when disassembling data, so we
won't lose anything if we just drop them.

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

tools/llvm-objdump/MCFunction.cpp

index eef58cd13e043e865f0fca3a0a263aeb256a8ed5..4a4f9d5e50a0cc882a288ec29c54a6428fd14bf8 100644 (file)
@@ -46,7 +46,10 @@ MCFunction::createFunctionFromMC(StringRef Name, const MCDisassembler *DisAsm,
           int64_t Imm = Inst.getOperand(0).getImm();
           // FIXME: Distinguish relocations from nop jumps.
           if (Imm != 0) {
-            assert(Index+Imm+Size < End && "Branch out of function.");
+            if (Index+Imm+Size >= End) {
+              Instructions.push_back(MCDecodedInst(Index, Size, Inst));
+              continue; // Skip branches that leave the function.
+            }
             Splits.insert(Index+Imm+Size);
           }
         }