[llvm-commits] [llvm] r49006 - in /llvm/trunk/lib: CodeGen/DwarfWriter.cpp CodeGen/LLVMTargetMachine.cpp CodeGen/SelectionDAG/SelectionDAGISel.cpp Target/PowerPC/PPCAsmPrinter.cpp Target/PowerPC/PPCRegisterInfo.cpp Target/X86/X86AsmPrinter.cpp Target/X86/X86RegisterInfo.cpp Transforms/Utils/LowerInvoke.cpp
Dale Johannesen
dalej at apple.com
Mon Mar 31 16:40:24 PDT 2008
Author: johannes
Date: Mon Mar 31 18:40:23 2008
New Revision: 49006
URL: http://llvm.org/viewvc/llvm-project?rev=49006&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/DwarfWriter.cpp
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Mon Mar 31 18:40:23 2008
@@ -2778,9 +2778,13 @@
std::vector<FunctionEHFrameInfo> EHFrames;
- /// shouldEmit - Flag to indicate if debug information should be emitted.
- ///
+ /// shouldEmit - Per-function flag to indicate if EH information should
+ /// be emitted.
bool shouldEmit;
+
+ /// shouldEmitModule - Per-module flag to indicate if EH information should
+ /// be emitted.
+ bool shouldEmitModule;
/// EmitCommonEHFrame - Emit the common eh unwind frame.
///
@@ -3368,6 +3372,7 @@
DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
: Dwarf(OS, A, T, "eh")
, shouldEmit(false)
+ , shouldEmitModule(false)
{}
virtual ~DwarfException() {}
@@ -3387,7 +3392,7 @@
/// EndModule - Emit all exception information that should come after the
/// content.
void EndModule() {
- if (!shouldEmit) return;
+ if (!shouldEmitModule) return;
const std::vector<Function *> Personalities = MMI->getPersonalities();
for (unsigned i =0; i < Personalities.size(); ++i)
@@ -3403,13 +3408,14 @@
void BeginFunction(MachineFunction *MF) {
this->MF = MF;
- if (MMI &&
- ExceptionHandling &&
+ shouldEmit = false;
+ if ((ExceptionHandling || !MF->getFunction()->doesNotThrow()) &&
TAI->doesSupportExceptionHandling()) {
shouldEmit = true;
// Assumes in correct section after the entry point.
EmitLabel("eh_func_begin", ++SubprogramCount);
}
+ shouldEmitModule |= shouldEmit;
}
/// EndFunction - Gather and emit post-function exception information.
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Mar 31 18:40:23 2008
@@ -66,8 +66,7 @@
PM.add(createGCLoweringPass());
- if (!ExceptionHandling)
- PM.add(createLowerInvokePass(getTargetLowering()));
+ PM.add(createLowerInvokePass(getTargetLowering()));
// Make sure that no unreachable blocks are instruction selected.
PM.add(createUnreachableBlockEliminationPass());
@@ -192,8 +191,7 @@
PM.add(createGCLoweringPass());
- if (!ExceptionHandling)
- PM.add(createLowerInvokePass(getTargetLowering()));
+ PM.add(createLowerInvokePass(getTargetLowering()));
// Make sure that no unreachable blocks are instruction selected.
PM.add(createUnreachableBlockEliminationPass());
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Mar 31 18:40:23 2008
@@ -169,6 +169,7 @@
Function &Fn;
MachineFunction &MF;
MachineRegisterInfo &RegInfo;
+ bool needsExceptionHandling;
FunctionLoweringInfo(TargetLowering &TLI, Function &Fn,MachineFunction &MF);
@@ -304,6 +305,10 @@
BuildMI(MBB, TII->get(TargetInstrInfo::PHI), PHIReg+i);
}
}
+
+ // Figure out whether we need to generate EH info. Currently we do this for
+ // all functions not marked no-unwind, or if requested via -enable-eh.
+ needsExceptionHandling = ExceptionHandling || !Fn.doesNotThrow();
}
/// CreateRegForValue - Allocate the appropriate number of virtual registers of
@@ -2827,7 +2832,7 @@
}
case Intrinsic::eh_exception: {
- if (ExceptionHandling) {
+ if (FuncInfo.needsExceptionHandling) {
if (!CurMBB->isLandingPad()) {
// FIXME: Mark exception register as live in. Hack for PR1508.
unsigned Reg = TLI.getExceptionAddressRegister();
@@ -2852,7 +2857,7 @@
MVT::ValueType VT = (Intrinsic == Intrinsic::eh_selector_i32 ?
MVT::i32 : MVT::i64);
- if (ExceptionHandling && MMI) {
+ if (FuncInfo.needsExceptionHandling && MMI) {
if (CurMBB->isLandingPad())
addCatchInfo(I, MMI, CurMBB);
else {
@@ -2902,7 +2907,7 @@
case Intrinsic::eh_return: {
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
- if (MMI && ExceptionHandling) {
+ if (MMI && FuncInfo.needsExceptionHandling) {
MMI->setCallsEHReturn(true);
DAG.setRoot(DAG.getNode(ISD::EH_RETURN,
MVT::Other,
@@ -2925,7 +2930,7 @@
}
case Intrinsic::eh_dwarf_cfa: {
- if (ExceptionHandling) {
+ if (FuncInfo.needsExceptionHandling) {
MVT::ValueType VT = getValue(I.getOperand(1)).getValueType();
SDOperand CfaArg;
if (MVT::getSizeInBits(VT) > MVT::getSizeInBits(TLI.getPointerTy()))
@@ -3176,7 +3181,7 @@
Args.push_back(Entry);
}
- if (LandingPad && ExceptionHandling && MMI) {
+ if (LandingPad && FuncInfo.needsExceptionHandling && MMI) {
// Insert a label before the invoke call to mark the try range. This can be
// used to detect deletion of the invoke via the MachineModuleInfo.
BeginLabel = MMI->NextLabelID();
@@ -3195,7 +3200,7 @@
setValue(CS.getInstruction(), Result.first);
DAG.setRoot(Result.second);
- if (LandingPad && ExceptionHandling && MMI) {
+ if (LandingPad && FuncInfo.needsExceptionHandling && MMI) {
// Insert a label at the end of the invoke call to mark the try range. This
// can be used to detect deletion of the invoke via the MachineModuleInfo.
EndLabel = MMI->NextLabelID();
@@ -4614,7 +4619,7 @@
FunctionLoweringInfo FuncInfo(TLI, Fn, MF);
- if (ExceptionHandling)
+ if (FuncInfo.needsExceptionHandling)
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
if (InvokeInst *Invoke = dyn_cast<InvokeInst>(I->getTerminator()))
// Mark landing pad.
@@ -4757,7 +4762,7 @@
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
- if (ExceptionHandling && MMI && BB->isLandingPad()) {
+ if (FuncInfo.needsExceptionHandling && MMI && BB->isLandingPad()) {
// Add a label to mark the beginning of the landing pad. Deletion of the
// landing pad can thus be detected via the MachineModuleInfo.
unsigned LabelID = MMI->addLandingPad(BB);
Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Mar 31 18:40:23 2008
@@ -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(),
Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Mar 31 18:40:23 2008
@@ -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) {
Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Mon Mar 31 18:40:23 2008
@@ -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(),
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Mar 31 18:40:23 2008
@@ -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();
Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=49006&r1=49005&r2=49006&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Mon Mar 31 18:40:23 2008
@@ -47,6 +47,9 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetLowering.h"
+#include "llvm/Target/TargetOptions.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetAsmInfo.h"
#include <csetjmp>
#include <set>
using namespace llvm;
@@ -592,6 +595,12 @@
}
bool LowerInvoke::runOnFunction(Function &F) {
+ // If we will be generating exception info, don't do anything here.
+ if ((ExceptionHandling || !F.doesNotThrow()) &&
+ TLI &&
+ TLI->getTargetMachine().getTargetAsmInfo()->
+ doesSupportExceptionHandling())
+ return false;
if (ExpensiveEHSupport)
return insertExpensiveEHSupport(F);
else
More information about the llvm-commits
mailing list