mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-23 19:59:57 +00:00
Allow multiple invokes per landing pad. This (probably) fixes PR1410.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36977 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c1fe16610a
commit
eeb37e0b80
@ -33,6 +33,7 @@
|
||||
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/UniqueVector.h"
|
||||
#include "llvm/GlobalValue.h"
|
||||
#include "llvm/Pass.h"
|
||||
@ -955,8 +956,8 @@ public:
|
||||
///
|
||||
struct LandingPadInfo {
|
||||
MachineBasicBlock *LandingPadBlock; // Landing pad block.
|
||||
unsigned BeginLabel; // Label prior to invoke.
|
||||
unsigned EndLabel; // Label after invoke.
|
||||
SmallVector<unsigned, 1> BeginLabels; // Labels prior to invoke.
|
||||
SmallVector<unsigned, 1> EndLabels; // Labels after invoke.
|
||||
unsigned LandingPadLabel; // Label at beginning of landing pad.
|
||||
Function *Personality; // Personality function.
|
||||
std::vector<unsigned> TypeIds; // List of type ids.
|
||||
@ -965,8 +966,6 @@ struct LandingPadInfo {
|
||||
|
||||
LandingPadInfo(MachineBasicBlock *MBB)
|
||||
: LandingPadBlock(MBB)
|
||||
, BeginLabel(0)
|
||||
, EndLabel(0)
|
||||
, LandingPadLabel(0)
|
||||
, TypeIds()
|
||||
, IsFilter(false)
|
||||
|
@ -2933,40 +2933,42 @@ private:
|
||||
const std::vector<unsigned> &TypeIds = LandingPad.TypeIds;
|
||||
unsigned SizeAction = 0;
|
||||
signed FirstAction;
|
||||
|
||||
if (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()) {
|
||||
FirstAction = 0;
|
||||
} else {
|
||||
// Gather the action sizes
|
||||
for (unsigned j = 0, M = TypeIds.size(); j != M; ++j) {
|
||||
unsigned TypeID = TypeIds[j];
|
||||
unsigned SizeTypeID = Asm->SizeSLEB128(TypeID);
|
||||
signed Action = j ? -(SizeAction + SizeTypeID) : 0;
|
||||
SizeAction = SizeTypeID + Asm->SizeSLEB128(Action);
|
||||
|
||||
for (unsigned j = 0, E = LandingPad.BeginLabels.size(); j != E; ++j) {
|
||||
if (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()) {
|
||||
FirstAction = 0;
|
||||
} else {
|
||||
// Gather the action sizes
|
||||
for (unsigned k = 0, M = TypeIds.size(); k != M; ++k) {
|
||||
unsigned TypeID = TypeIds[k];
|
||||
unsigned SizeTypeID = Asm->SizeSLEB128(TypeID);
|
||||
signed Action = k ? -(SizeAction + SizeTypeID) : 0;
|
||||
SizeAction = SizeTypeID + Asm->SizeSLEB128(Action);
|
||||
SizeSiteActions += SizeAction;
|
||||
}
|
||||
|
||||
// Record the first action of the landing pad site.
|
||||
FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
|
||||
// Record the first action of the landing pad site.
|
||||
FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
|
||||
}
|
||||
|
||||
Actions.push_back(FirstAction);
|
||||
|
||||
// Compute this sites contribution to size.
|
||||
SizeActions += SizeSiteActions;
|
||||
SizeSites += sizeof(int32_t) + // Site start.
|
||||
sizeof(int32_t) + // Site length.
|
||||
sizeof(int32_t) + // Landing pad.
|
||||
Asm->SizeSLEB128(FirstAction); // Action.
|
||||
}
|
||||
|
||||
Actions.push_back(FirstAction);
|
||||
|
||||
// Compute this sites contribution to size.
|
||||
SizeActions += SizeSiteActions;
|
||||
SizeSites += sizeof(int32_t) + // Site start.
|
||||
sizeof(int32_t) + // Site length.
|
||||
sizeof(int32_t) + // Landing pad.
|
||||
Asm->SizeSLEB128(FirstAction); // Action.
|
||||
}
|
||||
|
||||
// Final tallies.
|
||||
@ -2998,30 +3000,33 @@ private:
|
||||
Asm->EmitULEB128Bytes(SizeSites);
|
||||
Asm->EOL("Call-site table length");
|
||||
|
||||
// Emit the landng pad site information.
|
||||
// Emit the landing pad site information.
|
||||
for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
|
||||
const LandingPadInfo &LandingPad = LandingPads[i];
|
||||
EmitSectionOffset("label", "eh_func_begin",
|
||||
LandingPad.BeginLabel, SubprogramCount, false, true);
|
||||
Asm->EOL("Region start");
|
||||
for (unsigned j=0, E = LandingPad.BeginLabels.size(); j != E; ++j) {
|
||||
EmitSectionOffset("label", "eh_func_begin",
|
||||
LandingPad.BeginLabels[j], SubprogramCount,
|
||||
false, true);
|
||||
Asm->EOL("Region start");
|
||||
|
||||
EmitDifference("label", LandingPad.EndLabel,
|
||||
"label", LandingPad.BeginLabel);
|
||||
Asm->EOL("Region length");
|
||||
EmitDifference("label", LandingPad.EndLabels[j],
|
||||
"label", LandingPad.BeginLabels[j]);
|
||||
Asm->EOL("Region length");
|
||||
|
||||
if (LandingPad.TypeIds.empty()) {
|
||||
if (TAI->getAddressSize() == sizeof(int32_t))
|
||||
Asm->EmitInt32(0);
|
||||
else
|
||||
Asm->EmitInt64(0);
|
||||
} else {
|
||||
EmitSectionOffset("label", "eh_func_begin", LandingPad.LandingPadLabel,
|
||||
SubprogramCount, false, true);
|
||||
}
|
||||
Asm->EOL("Landing pad");
|
||||
if (LandingPad.TypeIds.empty()) {
|
||||
if (TAI->getAddressSize() == sizeof(int32_t))
|
||||
Asm->EmitInt32(0);
|
||||
else
|
||||
Asm->EmitInt64(0);
|
||||
} else {
|
||||
EmitSectionOffset("label", "eh_func_begin", LandingPad.LandingPadLabel,
|
||||
SubprogramCount, false, true);
|
||||
}
|
||||
Asm->EOL("Landing pad");
|
||||
|
||||
Asm->EmitULEB128Bytes(Actions[i]);
|
||||
Asm->EOL("Action");
|
||||
Asm->EmitULEB128Bytes(Actions[i]);
|
||||
Asm->EOL("Action");
|
||||
}
|
||||
}
|
||||
|
||||
// Emit the actions.
|
||||
|
@ -1669,8 +1669,8 @@ LandingPadInfo &MachineModuleInfo::getOrCreateLandingPadInfo
|
||||
void MachineModuleInfo::addInvoke(MachineBasicBlock *LandingPad,
|
||||
unsigned BeginLabel, unsigned EndLabel) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
if (!LP.BeginLabel) LP.BeginLabel = BeginLabel;
|
||||
LP.EndLabel = EndLabel;
|
||||
LP.BeginLabels.push_back(BeginLabel);
|
||||
LP.EndLabels.push_back(EndLabel);
|
||||
}
|
||||
|
||||
/// addLandingPad - Provide the label of a try LandingPad block.
|
||||
@ -1711,16 +1711,29 @@ void MachineModuleInfo::setIsFilterLandingPad(MachineBasicBlock *LandingPad) {
|
||||
void MachineModuleInfo::TidyLandingPads() {
|
||||
for (unsigned i = 0; i != LandingPads.size(); ) {
|
||||
LandingPadInfo &LandingPad = LandingPads[i];
|
||||
LandingPad.BeginLabel = MappedLabel(LandingPad.BeginLabel);
|
||||
LandingPad.EndLabel = MappedLabel(LandingPad.EndLabel);
|
||||
LandingPad.LandingPadLabel = MappedLabel(LandingPad.LandingPadLabel);
|
||||
|
||||
if (!LandingPad.BeginLabel ||
|
||||
!LandingPad.EndLabel ||
|
||||
!LandingPad.LandingPadLabel) {
|
||||
|
||||
if (!LandingPad.LandingPadLabel) {
|
||||
LandingPads.erase(LandingPads.begin() + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned j=0; j != LandingPads[i].BeginLabels.size(); ) {
|
||||
unsigned BeginLabel = MappedLabel(LandingPad.BeginLabels[j]);
|
||||
unsigned EndLabel = MappedLabel(LandingPad.EndLabels[j]);
|
||||
|
||||
|
||||
if (!BeginLabel || !EndLabel) {
|
||||
printf("Tidy: %d, %d, %d\n", BeginLabel, EndLabel, LandingPad.LandingPadLabel);
|
||||
LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
|
||||
LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
|
||||
continue;
|
||||
}
|
||||
|
||||
LandingPad.BeginLabels[j] = BeginLabel;
|
||||
LandingPad.EndLabels[j] = EndLabel;
|
||||
++j;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user