aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/DwarfWriter.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-06-02 16:53:42 +0000
committerDuncan Sands <baldrick@free.fr>2007-06-02 16:53:42 +0000
commit73ef58ab92d5cd23b119b7f206e5f8a8c529098d (patch)
tree6cf1db0c4b0ff8d89c195a92d8d25d19b38b257c /lib/CodeGen/DwarfWriter.cpp
parent02031c0ff8ad48acdb8c4a4058c4fafe600423e1 (diff)
downloadexternal_llvm-73ef58ab92d5cd23b119b7f206e5f8a8c529098d.tar.gz
external_llvm-73ef58ab92d5cd23b119b7f206e5f8a8c529098d.tar.bz2
external_llvm-73ef58ab92d5cd23b119b7f206e5f8a8c529098d.zip
Integrate exception filter support and exception catch support. This
simplifies the code in DwarfWriter, allows for multiple filters and makes it trivial to specify filters accompanied by cleanups or catch-all specifications (see next patch). What a deal! Patch blessed by Anton. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfWriter.cpp')
-rw-r--r--lib/CodeGen/DwarfWriter.cpp74
1 files changed, 21 insertions, 53 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index 7e97788bc1..5ab399705a 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -2896,13 +2896,10 @@ private:
/// EquivPads - Whether two landing pads have equivalent actions.
static bool EquivPads(const LandingPadInfo *L, const LandingPadInfo *R) {
- const std::vector<unsigned> &LIds = L->TypeIds;
- const std::vector<unsigned> &RIds = R->TypeIds;
+ const std::vector<int> &LIds = L->TypeIds;
+ const std::vector<int> &RIds = R->TypeIds;
unsigned LSize = LIds.size(), RSize = RIds.size();
- if (L->IsFilter != R->IsFilter)
- return false;
-
if (LSize != RSize)
return false;
@@ -2915,14 +2912,10 @@ private:
/// PadLT - An order on landing pads, with EquivPads as order equivalence.
static bool PadLT(const LandingPadInfo *L, const LandingPadInfo *R) {
- const std::vector<unsigned> &LIds = L->TypeIds;
- const std::vector<unsigned> &RIds = R->TypeIds;
+ const std::vector<int> &LIds = L->TypeIds;
+ const std::vector<int> &RIds = R->TypeIds;
unsigned LSize = LIds.size(), RSize = RIds.size();
- if (L->IsFilter != R->IsFilter)
- // Make filters come last
- return L->IsFilter < R->IsFilter;
-
if (LSize != RSize)
return LSize < RSize;
@@ -2972,6 +2965,7 @@ private:
MMI->TidyLandingPads();
const std::vector<GlobalVariable *> &TypeInfos = MMI->getTypeInfos();
+ const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
const std::vector<LandingPadInfo> &PadInfos = MMI->getLandingPads();
if (PadInfos.empty()) return;
@@ -2985,11 +2979,6 @@ private:
// Gather first action index for each landing pad site.
SmallVector<unsigned, 32> Actions;
- // FIXME - Assume there is only one filter typeinfo list per function
- // time being. I.E., Each call to eh_filter will have the same list.
- // This can change if a function is inlined.
- const LandingPadInfo *Filter = 0;
-
// Compute sizes for exception table.
unsigned SizeSites = 0;
unsigned SizeActions = 0;
@@ -3003,24 +2992,15 @@ private:
unsigned SizeSiteActions = 0;
if (!i || !EquivPads(LandingPad, LandingPads[i-1])) {
- const std::vector<unsigned> &TypeIds = LandingPad->TypeIds;
+ const std::vector<int> &TypeIds = LandingPad->TypeIds;
unsigned SizeAction = 0;
- if (LandingPad->IsFilter) {
- // FIXME - Assume there is only one filter typeinfo list per function
- // time being. I.E., Each call to eh_filter will have the same list.
- // This can change if a function is inlined.
- Filter = LandingPad;
- SizeAction = Asm->SizeSLEB128(-1) + Asm->SizeSLEB128(0);
- SizeSiteActions += SizeAction;
- // Record the first action of the landing pad site.
- FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
- } else if (TypeIds.empty()) {
+ if (TypeIds.empty()) {
FirstAction = 0;
} else {
// Gather the action sizes
for (unsigned j = 0, M = TypeIds.size(); j != M; ++j) {
- unsigned TypeID = TypeIds[j];
+ int TypeID = TypeIds[j];
unsigned SizeTypeID = Asm->SizeSLEB128(TypeID);
signed Action = j ? -(SizeAction + SizeTypeID) : 0;
SizeAction = SizeTypeID + Asm->SizeSLEB128(Action);
@@ -3140,25 +3120,18 @@ private:
for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
if (!i || Actions[i] != Actions[i-1]) {
const LandingPadInfo *LandingPad = LandingPads[i];
- const std::vector<unsigned> &TypeIds = LandingPad->TypeIds;
+ const std::vector<int> &TypeIds = LandingPad->TypeIds;
unsigned SizeAction = 0;
- if (LandingPad->IsFilter) {
- Asm->EmitSLEB128Bytes(-1);
+ for (unsigned j = 0, M = TypeIds.size(); j < M; ++j) {
+ int TypeID = TypeIds[j];
+ unsigned SizeTypeID = Asm->SizeSLEB128(TypeID);
+ Asm->EmitSLEB128Bytes(TypeID);
Asm->EOL("TypeInfo index");
- Asm->EmitSLEB128Bytes(0);
+ signed Action = j ? -(SizeAction + SizeTypeID) : 0;
+ SizeAction = SizeTypeID + Asm->SizeSLEB128(Action);
+ Asm->EmitSLEB128Bytes(Action);
Asm->EOL("Next action");
- } else {
- for (unsigned j = 0, M = TypeIds.size(); j < M; ++j) {
- unsigned TypeID = TypeIds[j];
- unsigned SizeTypeID = Asm->SizeSLEB128(TypeID);
- Asm->EmitSLEB128Bytes(TypeID);
- Asm->EOL("TypeInfo index");
- signed Action = j ? -(SizeAction + SizeTypeID) : 0;
- SizeAction = SizeTypeID + Asm->SizeSLEB128(Action);
- Asm->EmitSLEB128Bytes(Action);
- Asm->EOL("Next action");
- }
}
}
}
@@ -3180,16 +3153,11 @@ private:
Asm->EOL("TypeInfo");
}
- // Emit the filter typeinfo.
- if (Filter) {
- const std::vector<unsigned> &TypeIds = Filter->TypeIds;
- for (unsigned j = 0, M = TypeIds.size(); j < M; ++j) {
- unsigned TypeID = TypeIds[j];
- Asm->EmitSLEB128Bytes(TypeID);
- Asm->EOL("TypeInfo index");
- }
- Asm->EmitSLEB128Bytes(0);
- Asm->EOL("End of filter typeinfo");
+ // Emit the filter typeids.
+ for (unsigned j = 0, M = FilterIds.size(); j < M; ++j) {
+ unsigned TypeID = FilterIds[j];
+ Asm->EmitSLEB128Bytes(TypeID);
+ Asm->EOL("Filter TypeInfo index");
}
Asm->EmitAlignment(2);