diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-09-25 19:56:44 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-09-25 19:56:44 +0000 |
commit | e41be38efd9465d34a701476de455395f3512799 (patch) | |
tree | 331baa7433af05fef51274189d2199d360c8e1aa /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | e38c7f8d969779d2a1513a3a1809d05aa2160db5 (diff) | |
download | bcm5719-llvm-e41be38efd9465d34a701476de455395f3512799.tar.gz bcm5719-llvm-e41be38efd9465d34a701476de455395f3512799.zip |
Unify landing pad information adding routines (NFC)
Summary:
We have `llvm::addLandingPadInfo` and `MachineFunction::addLandingPad`,
both of which add landing pad information to populate `LandingPadInfo`
but are called from different locations, which was confusing. This patch
unifies them with one `MachineFunction::addLandingPad` function, which
now has functionlities of both functions.
Reviewers: rnk
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D52428
llvm-svn: 343018
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 81fc47bd573..86c316245a1 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -626,6 +626,44 @@ MCSymbol *MachineFunction::addLandingPad(MachineBasicBlock *LandingPad) { MCSymbol *LandingPadLabel = Ctx.createTempSymbol(); LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); LP.LandingPadLabel = LandingPadLabel; + + const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI(); + if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) { + if (const auto *PF = + dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts())) + getMMI().addPersonality(PF); + + if (LPI->isCleanup()) + addCleanup(LandingPad); + + // FIXME: New EH - Add the clauses in reverse order. This isn't 100% + // correct, + // but we need to do it this way because of how the DWARF EH emitter + // processes the clauses. + for (unsigned I = LPI->getNumClauses(); I != 0; --I) { + Value *Val = LPI->getClause(I - 1); + if (LPI->isCatch(I - 1)) { + addCatchTypeInfo(LandingPad, + dyn_cast<GlobalValue>(Val->stripPointerCasts())); + } else { + // Add filters in a list. + auto *CVal = cast<Constant>(Val); + SmallVector<const GlobalValue *, 4> FilterList; + for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end(); + II != IE; ++II) + FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts())); + + addFilterTypeInfo(LandingPad, FilterList); + } + } + + } else if (const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) { + // TODO + + } else { + assert(isa<CleanupPadInst>(FirstI) && "Invalid landingpad!"); + } + return LandingPadLabel; } @@ -754,36 +792,6 @@ try_next:; return FilterID; } -void llvm::addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB) { - MachineFunction &MF = *MBB.getParent(); - if (const auto *PF = dyn_cast<Function>( - I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts())) - MF.getMMI().addPersonality(PF); - - if (I.isCleanup()) - MF.addCleanup(&MBB); - - // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct, - // but we need to do it this way because of how the DWARF EH emitter - // processes the clauses. - for (unsigned i = I.getNumClauses(); i != 0; --i) { - Value *Val = I.getClause(i - 1); - if (I.isCatch(i - 1)) { - MF.addCatchTypeInfo(&MBB, - dyn_cast<GlobalValue>(Val->stripPointerCasts())); - } else { - // Add filters in a list. - Constant *CVal = cast<Constant>(Val); - SmallVector<const GlobalValue *, 4> FilterList; - for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end(); - II != IE; ++II) - FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts())); - - MF.addFilterTypeInfo(&MBB, FilterList); - } - } -} - /// \} //===----------------------------------------------------------------------===// |