aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/DwarfWriter.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-04-02 00:25:04 +0000
committerDale Johannesen <dalej@apple.com>2008-04-02 00:25:04 +0000
commit1532f3ddd77c362dd5f613af06b4de636e3c5b0e (patch)
tree52fd71de9a6648a1f69dca1dd3d87ced1bc2adf5 /lib/CodeGen/DwarfWriter.cpp
parent7c3becd9d729b976d79b18e6165e74390e613bb5 (diff)
Recommitting EH patch; this should answer most of the
review feedback. -enable-eh is still accepted but doesn't do anything. EH intrinsics use Dwarf EH if the target supports that, and are handled by LowerInvoke otherwise. The separation of the EH table and frame move data is, I think, logically figured out, but either one still causes full EH info to be generated (not sure how to split the metadata correctly). MachineModuleInfo::needsFrameInfo is no longer used and is removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfWriter.cpp')
-rw-r--r--lib/CodeGen/DwarfWriter.cpp85
1 files changed, 54 insertions, 31 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index e72ff07a9d..0fa956e097 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -2777,10 +2777,22 @@ private:
};
std::vector<FunctionEHFrameInfo> EHFrames;
-
- /// shouldEmit - Flag to indicate if debug information should be emitted.
- ///
- bool shouldEmit;
+
+ /// shouldEmitTable - Per-function flag to indicate if EH tables should
+ /// be emitted.
+ bool shouldEmitTable;
+
+ /// shouldEmitMoves - Per-function flag to indicate if frame moves info
+ /// should be emitted.
+ bool shouldEmitMoves;
+
+ /// shouldEmitTableModule - Per-module flag to indicate if EH tables
+ /// should be emitted.
+ bool shouldEmitTableModule;
+
+ /// shouldEmitFrameModule - Per-module flag to indicate if frame moves
+ /// should be emitted.
+ bool shouldEmitMovesModule;
/// EmitCommonEHFrame - Emit the common eh unwind frame.
///
@@ -3045,9 +3057,6 @@ private:
};
void EmitExceptionTable() {
- // Map all labels and get rid of any dead landing pads.
- MMI->TidyLandingPads();
-
const std::vector<GlobalVariable *> &TypeInfos = MMI->getTypeInfos();
const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
const std::vector<LandingPadInfo> &PadInfos = MMI->getLandingPads();
@@ -3367,7 +3376,10 @@ public:
//
DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
: Dwarf(OS, A, T, "eh")
- , shouldEmit(false)
+ , shouldEmitTable(false)
+ , shouldEmitMoves(false)
+ , shouldEmitTableModule(false)
+ , shouldEmitMovesModule(false)
{}
virtual ~DwarfException() {}
@@ -3387,48 +3399,59 @@ public:
/// EndModule - Emit all exception information that should come after the
/// content.
void EndModule() {
- if (!shouldEmit) return;
-
- const std::vector<Function *> Personalities = MMI->getPersonalities();
- for (unsigned i =0; i < Personalities.size(); ++i)
- EmitCommonEHFrame(Personalities[i], i);
-
- for (std::vector<FunctionEHFrameInfo>::iterator I = EHFrames.begin(),
- E = EHFrames.end(); I != E; ++I)
- EmitEHFrame(*I);
+ if (shouldEmitMovesModule || shouldEmitTableModule) {
+ const std::vector<Function *> Personalities = MMI->getPersonalities();
+ for (unsigned i =0; i < Personalities.size(); ++i)
+ EmitCommonEHFrame(Personalities[i], i);
+
+ for (std::vector<FunctionEHFrameInfo>::iterator I = EHFrames.begin(),
+ E = EHFrames.end(); I != E; ++I)
+ EmitEHFrame(*I);
+ }
}
/// BeginFunction - Gather pre-function exception information. Assumes being
/// emitted immediately after the function entry point.
void BeginFunction(MachineFunction *MF) {
this->MF = MF;
-
- if (MMI &&
- ExceptionHandling &&
- TAI->doesSupportExceptionHandling()) {
- shouldEmit = true;
- // Assumes in correct section after the entry point.
- EmitLabel("eh_func_begin", ++SubprogramCount);
+ shouldEmitTable = shouldEmitMoves = false;
+ if (TAI->doesSupportExceptionHandling()) {
+
+ // Map all labels and get rid of any dead landing pads.
+ MMI->TidyLandingPads();
+ // If any landing pads survive, we need an EH table.
+ if (MMI->getLandingPads().size())
+ shouldEmitTable = true;
+
+ // See if we need frame move info.
+ if (MMI->hasDebugInfo() || !MF->getFunction()->doesNotThrow())
+ shouldEmitMoves = true;
+
+ if (shouldEmitMoves || shouldEmitTable)
+ // Assumes in correct section after the entry point.
+ EmitLabel("eh_func_begin", ++SubprogramCount);
}
+ shouldEmitTableModule |= shouldEmitTable;
+ shouldEmitMovesModule |= shouldEmitMoves;
}
/// EndFunction - Gather and emit post-function exception information.
///
void EndFunction() {
- if (!shouldEmit) return;
+ if (shouldEmitMoves || shouldEmitTable) {
+ EmitLabel("eh_func_end", SubprogramCount);
+ EmitExceptionTable();
- EmitLabel("eh_func_end", SubprogramCount);
- EmitExceptionTable();
-
- // Save EH frame information
- EHFrames.
- push_back(FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF),
+ // Save EH frame information
+ EHFrames.
+ push_back(FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF),
SubprogramCount,
MMI->getPersonalityIndex(),
MF->getFrameInfo()->hasCalls(),
!MMI->getLandingPads().empty(),
MMI->getFrameMoves(),
MF->getFunction()));
+ }
}
};