diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/LibCallSemantics.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/ARMException.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 57 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 14 |
7 files changed, 22 insertions, 82 deletions
diff --git a/llvm/lib/Analysis/LibCallSemantics.cpp b/llvm/lib/Analysis/LibCallSemantics.cpp index 36b92c38e89..0ae13dd5afb 100644 --- a/llvm/lib/Analysis/LibCallSemantics.cpp +++ b/llvm/lib/Analysis/LibCallSemantics.cpp @@ -21,7 +21,8 @@ using namespace llvm; /// See if the given exception handling personality function is one that we /// understand. If so, return a description of it; otherwise return Unknown. EHPersonality llvm::classifyEHPersonality(const Value *Pers) { - const Function *F = dyn_cast<Function>(Pers->stripPointerCasts()); + const Function *F = + Pers ? dyn_cast<Function>(Pers->stripPointerCasts()) : nullptr; if (!F) return EHPersonality::Unknown; return StringSwitch<EHPersonality>(F->getName()) diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp index 462e5d19c8d..ade2d7105b8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp @@ -73,7 +73,6 @@ void ARMException::endFunction(const MachineFunction *MF) { const Function *Per = nullptr; if (F->hasPersonalityFn()) Per = dyn_cast<Function>(F->getPersonalityFn()->stripPointerCasts()); - assert(!MMI->getPersonality() || Per == MMI->getPersonality()); bool forceEmitPersonality = F->hasPersonalityFn() && !isNoOpWithoutInvoke(classifyEHPersonality(Per)) && F->needsUnwindTableEntry(); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 282e2ec31a9..6665c16159a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -78,11 +78,10 @@ void DwarfCFIException::endModule() { return; // Emit references to all used personality functions - const std::vector<const Function*> &Personalities = MMI->getPersonalities(); - for (size_t i = 0, e = Personalities.size(); i != e; ++i) { - if (!Personalities[i]) + for (const Function *Personality : MMI->getPersonalities()) { + if (!Personality) continue; - MCSymbol *Sym = Asm->getSymbol(Personalities[i]); + MCSymbol *Sym = Asm->getSymbol(Personality); TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym); } } @@ -108,7 +107,6 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { const Function *Per = nullptr; if (F->hasPersonalityFn()) Per = dyn_cast<Function>(F->getPersonalityFn()->stripPointerCasts()); - assert(!MMI->getPersonality() || Per == MMI->getPersonality()); // Emit a personality function even when there are no landing pads bool forceEmitPersonality = diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 6f9721a0d35..ee5852a8f93 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -211,8 +211,6 @@ bool MachineModuleInfo::doInitialization(Module &M) { CallsUnwindInit = false; HasEHFunclets = false; DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false; - // Always emit some info, by default "no personality" info. - Personalities.push_back(nullptr); PersonalityTypeCache = EHPersonality::Unknown; AddrLabelSymbols = nullptr; TheModule = nullptr; @@ -316,26 +314,11 @@ MCSymbol *MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) { return LandingPadLabel; } -/// addPersonality - Provide the personality function for the exception -/// information. -void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad, - const Function *Personality) { - LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); - LP.Personality = Personality; - addPersonality(Personality); -} - void MachineModuleInfo::addPersonality(const Function *Personality) { for (unsigned i = 0; i < Personalities.size(); ++i) if (Personalities[i] == Personality) return; - - // If this is the first personality we're adding go - // ahead and add it at the beginning. - if (!Personalities[0]) - Personalities[0] = Personality; - else - Personalities.push_back(Personality); + Personalities.push_back(Personality); } void MachineModuleInfo::addWinEHState(MachineBasicBlock *LandingPad, @@ -484,44 +467,6 @@ try_next:; return FilterID; } -/// getPersonality - Return the personality function for the current function. -const Function *MachineModuleInfo::getPersonality() const { - for (const LandingPadInfo &LPI : LandingPads) - if (LPI.Personality) - return LPI.Personality; - return nullptr; -} - -EHPersonality MachineModuleInfo::getPersonalityType() { - if (PersonalityTypeCache == EHPersonality::Unknown) { - if (const Function *F = getPersonality()) - PersonalityTypeCache = classifyEHPersonality(F); - } - return PersonalityTypeCache; -} - -/// getPersonalityIndex - Return unique index for current personality -/// function. NULL/first personality function should always get zero index. -unsigned MachineModuleInfo::getPersonalityIndex() const { - const Function* Personality = nullptr; - - // Scan landing pads. If there is at least one non-NULL personality - use it. - for (unsigned i = 0, e = LandingPads.size(); i != e; ++i) - if (LandingPads[i].Personality) { - Personality = LandingPads[i].Personality; - break; - } - - for (unsigned i = 0, e = Personalities.size(); i < e; ++i) { - if (Personalities[i] == Personality) - return i; - } - - // This will happen if the current personality function is - // in the zero index. - return 0; -} - const Function *MachineModuleInfo::getWinEHParent(const Function *F) const { StringRef WinEHParentName = F->getFnAttribute("wineh-parent").getValueAsString(); diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index c0d14c1780d..7a45858885d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -553,10 +553,9 @@ void llvm::ComputeUsesVAFloatArgument(const CallInst &I, /// landingpad instruction and add them to the specified machine module info. void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, MachineBasicBlock *MBB) { - MMI.addPersonality( - MBB, - cast<Function>( - I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts())); + if (const auto *PF = dyn_cast<Function>( + I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts())) + MMI.addPersonality(PF); if (I.isCleanup()) MMI.addCleanup(MBB); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index be6ccb3ac61..2c5c1682e34 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -945,14 +945,12 @@ bool SelectionDAGISel::PrepareEHLandingPad() { // If this is an MSVC-style personality function, we need to split the landing // pad into several BBs. const BasicBlock *LLVMBB = MBB->getBasicBlock(); - const LandingPadInst *LPadInst = LLVMBB->getLandingPadInst(); - MF->getMMI().addPersonality(MBB, cast<Function>(LPadInst->getParent() - ->getParent() - ->getPersonalityFn() - ->stripPointerCasts())); - EHPersonality Personality = MF->getMMI().getPersonalityType(); - - if (isMSVCEHPersonality(Personality)) { + const Constant *Personality = MF->getFunction()->getPersonalityFn(); + if (const auto *PF = dyn_cast<Function>(Personality->stripPointerCasts())) + MF->getMMI().addPersonality(PF); + EHPersonality PersonalityType = classifyEHPersonality(Personality); + + if (isMSVCEHPersonality(PersonalityType)) { SmallVector<MachineBasicBlock *, 4> ClauseBBs; const IntrinsicInst *ActionsCall = dyn_cast<IntrinsicInst>(LLVMBB->getFirstInsertionPt()); diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index a779338408e..dd432bcbae5 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1484,14 +1484,14 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { if (MAI->doesSupportExceptionHandling() && MMI) { // Add the (possibly multiple) personalities to the set of global values. // Only referenced functions get into the Personalities list. - const std::vector<const Function*> &Personalities = MMI->getPersonalities(); - for (std::vector<const Function*>::const_iterator I = Personalities.begin(), - E = Personalities.end(); I != E; ++I) { - if (*I) { - MCSymbol *NLPSym = getSymbolWithGlobalValueBase(*I, "$non_lazy_ptr"); + for (const Function *Personality : MMI->getPersonalities()) { + if (Personality) { + MCSymbol *NLPSym = + getSymbolWithGlobalValueBase(Personality, "$non_lazy_ptr"); MachineModuleInfoImpl::StubValueTy &StubSym = - MMIMacho.getGVStubEntry(NLPSym); - StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(*I), true); + MMIMacho.getGVStubEntry(NLPSym); + StubSym = + MachineModuleInfoImpl::StubValueTy(getSymbol(Personality), true); } } } |