aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineModuleInfo.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-05-13 15:42:26 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-05-13 15:42:26 +0000
commit8c7c17354c7d954de95a064ee89f8c82cccdb819 (patch)
tree7f901638144cecef38421a01b7a4012cd7622300 /lib/CodeGen/MachineModuleInfo.cpp
parent69b3e40196f837d5dbc484cd708b6e0489085787 (diff)
Emit multiple common EH frames for multiple (including blank) personality
functions. This partly fixes PR1414: now we're restricted only to one personality function per eh frame, not per module. Further work on "multiple personalities" topic needs representative example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r--lib/CodeGen/MachineModuleInfo.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp
index 22172811dc..d4d132989e 100644
--- a/lib/CodeGen/MachineModuleInfo.cpp
+++ b/lib/CodeGen/MachineModuleInfo.cpp
@@ -1475,8 +1475,11 @@ MachineModuleInfo::MachineModuleInfo()
, RootScope(NULL)
, FrameMoves()
, LandingPads()
-, Personality(NULL)
-{}
+, Personalities()
+{
+ // Always emit "no personality" info
+ Personalities.push_back(NULL);
+}
MachineModuleInfo::~MachineModuleInfo() {
}
@@ -1686,13 +1689,15 @@ unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
/// addPersonality - Provide the personality function for the exception
/// information.
void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad,
- Function *PersFn) {
+ Function *Personality) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
- LP.Personality = PersFn;
+ LP.Personality = Personality;
- // FIXME: Until PR1414 will be fixed, we're using 1 personality function per
- // module
- Personality = PersFn;
+ for (unsigned i = 0; i < Personalities.size(); ++i)
+ if (Personalities[i] == Personality)
+ return;
+
+ Personalities.push_back(Personality);
}
/// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
@@ -1753,16 +1758,28 @@ unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) {
return TypeInfos.size();
}
-/// getLandingPadInfos - Return a reference to the landing pad info for the
-/// current function.
+/// getPersonality - Return the personality function for the current function.
Function *MachineModuleInfo::getPersonality() const {
// FIXME: Until PR1414 will be fixed, we're using 1 personality function per
- // module
-
- //return !LandingPads.empty() ? LandingPads[0].Personality : NULL;
- return Personality;
+ // function
+ return !LandingPads.empty() ? LandingPads[0].Personality : NULL;
}
+/// getPersonalityIndex - Return unique index for current personality
+/// function. NULL personality function should always get zero index.
+unsigned MachineModuleInfo::getPersonalityIndex() const {
+ const Function* Personality = (!LandingPads.empty() ?
+ LandingPads[0].Personality : NULL);
+
+ for (unsigned i = 0; i < Personalities.size(); ++i) {
+ if (Personalities[i] == Personality)
+ return i;
+ }
+
+ // This should never happen
+ assert(0 && "Personality function should be set!");
+ return 0;
+}
//===----------------------------------------------------------------------===//
/// DebugLabelFolding pass - This pass prunes out redundant labels. This allows