Emit exception handling info for functions which are
not marked nounwind, or for all functions when -enable-eh
is set, provided the target supports Dwarf EH.
llvm-gcc generates nounwind in the right places; other FEs
will need to do so also. Given such a FE, -enable-eh should
no longer be needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49006 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 2537d67..4cc9d2a 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1086,8 +1086,9 @@
O << "\n";
- if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI) {
+ if (TAI->doesSupportExceptionHandling() && MMI) {
// Add the (possibly multiple) personalities to the set of global values.
+ // Only referenced functions get into the Personalities list.
const std::vector<Function *>& Personalities = MMI->getPersonalities();
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 0e6bc69..cc3b583 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -20,6 +20,7 @@
#include "PPCFrameInfo.h"
#include "PPCSubtarget.h"
#include "llvm/Constants.h"
+#include "llvm/Function.h"
#include "llvm/Type.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -946,6 +947,8 @@
MachineBasicBlock::iterator MBBI = MBB.begin();
MachineFrameInfo *MFI = MF.getFrameInfo();
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
+ bool needsFrameInfo = (MMI && MMI->hasDebugInfo()) ||
+ ExceptionHandling || !MF.getFunction()->doesNotThrow();
// Prepare for frame info.
unsigned FrameLabelId = 0;
@@ -1019,7 +1022,7 @@
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
unsigned MaxAlign = MFI->getMaxAlignment();
- if (MMI && MMI->needsFrameInfo()) {
+ if (needsFrameInfo) {
// Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID();
BuildMI(MBB, MBBI, TII.get(PPC::LABEL)).addImm(FrameLabelId).addImm(0);
@@ -1095,7 +1098,7 @@
}
}
- if (MMI && MMI->needsFrameInfo()) {
+ if (needsFrameInfo) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves();
if (NegFrameSize) {
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index 98e7d9c..e1bc65f 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -381,9 +381,9 @@
O << "\n";
- if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI &&
- !Subtarget->is64Bit()) {
+ if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
// Add the (possibly multiple) personalities to the set of global values.
+ // Only referenced functions get into the Personalities list.
const std::vector<Function *>& Personalities = MMI->getPersonalities();
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp
index 5cd2fbe..95026f2 100644
--- a/lib/Target/X86/X86RegisterInfo.cpp
+++ b/lib/Target/X86/X86RegisterInfo.cpp
@@ -504,6 +504,8 @@
MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
MachineBasicBlock::iterator MBBI = MBB.begin();
+ bool needsFrameInfo = (MMI && MMI->hasDebugInfo()) ||
+ ExceptionHandling || !Fn->doesNotThrow();
// Prepare for frame info.
unsigned FrameLabelId = 0;
@@ -536,7 +538,7 @@
.addReg(FramePtr);
NumBytes -= SlotSize;
- if (MMI && MMI->needsFrameInfo()) {
+ if (needsFrameInfo) {
// Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID();
BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(FrameLabelId).addImm(0);
@@ -548,7 +550,7 @@
}
unsigned ReadyLabelId = 0;
- if (MMI && MMI->needsFrameInfo()) {
+ if (needsFrameInfo) {
// Mark effective beginning of when frame pointer is ready.
ReadyLabelId = MMI->NextLabelID();
BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(ReadyLabelId).addImm(0);
@@ -607,7 +609,7 @@
}
}
- if (MMI && MMI->needsFrameInfo()) {
+ if (needsFrameInfo) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves();
const TargetData *TD = MF.getTarget().getTargetData();