Check hasPersonalityFn before calling getPersonalityFn
llvm-svn: 304365
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4391e80..e61e22a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -954,11 +954,12 @@
if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI->hasDebugInfo())
return true;
- // We might emit an LSDA anyway if we have an EH personality.
- const Constant *PerFn = MF.getFunction()->getPersonalityFn();
- if (!PerFn)
+ // We might emit an EH table that uses function begin and end labels even if
+ // we don't have any landingpads.
+ if (!MF.getFunction()->hasPersonalityFn())
return false;
- return !isNoOpWithoutInvoke(classifyEHPersonality(PerFn));
+ return !isNoOpWithoutInvoke(
+ classifyEHPersonality(MF.getFunction()->getPersonalityFn()));
}
/// EmitFunctionBody - This method emits the body and trailer for a