diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:04 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:11 +0000 |
| commit | e3b557809604d036af6e00c60f012c2025b59a5e (patch) | |
| tree | 8a11ba2269a3b669601e2fd41145b174008f4da8 /llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | |
| parent | 08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff) | |
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 72 |
1 files changed, 22 insertions, 50 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 5f187acf13dc..df4fe8d49806 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -23,28 +23,15 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; -DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A) : EHStreamer(A) {} +DwarfCFIException::DwarfCFIException(AsmPrinter *A) : EHStreamer(A) {} -void DwarfCFIExceptionBase::markFunctionEnd() { - endFragment(); - - // Map all labels and get rid of any dead landing pads. - if (!Asm->MF->getLandingPads().empty()) { - MachineFunction *NonConstMF = const_cast<MachineFunction*>(Asm->MF); - NonConstMF->tidyLandingPads(); - } -} +DwarfCFIException::~DwarfCFIException() = default; -void DwarfCFIExceptionBase::endFragment() { - if (shouldEmitCFI && !Asm->MF->hasBBSections()) - Asm->OutStreamer->emitCFIEndProc(); +void DwarfCFIException::addPersonality(const GlobalValue *Personality) { + if (!llvm::is_contained(Personalities, Personality)) + Personalities.push_back(Personality); } -DwarfCFIException::DwarfCFIException(AsmPrinter *A) - : DwarfCFIExceptionBase(A) {} - -DwarfCFIException::~DwarfCFIException() = default; - /// endModule - Emit all exception information that should come after the /// content. void DwarfCFIException::endModule() { @@ -59,18 +46,12 @@ void DwarfCFIException::endModule() { if ((PerEncoding & 0x80) != dwarf::DW_EH_PE_indirect) return; - // Emit references to all used personality functions - for (const Function *Personality : MMI->getPersonalities()) { - if (!Personality) - continue; + // Emit indirect reference table for all used personality functions + for (const GlobalValue *Personality : Personalities) { MCSymbol *Sym = Asm->getSymbol(Personality); TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym); } -} - -static MCSymbol *getExceptionSym(AsmPrinter *Asm, - const MachineBasicBlock *MBB) { - return Asm->getMBBExceptionSym(*MBB); + Personalities.clear(); } void DwarfCFIException::beginFunction(const MachineFunction *MF) { @@ -86,9 +67,9 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned PerEncoding = TLOF.getPersonalityEncoding(); - const Function *Per = nullptr; + const GlobalValue *Per = nullptr; if (F.hasPersonalityFn()) - Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()); + Per = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts()); // Emit a personality function even when there are no landing pads forceEmitPersonality = @@ -114,12 +95,9 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves); else shouldEmitCFI = Asm->needsCFIForDebug() && shouldEmitMoves; - - beginFragment(&*MF->begin(), getExceptionSym); } -void DwarfCFIException::beginFragment(const MachineBasicBlock *MBB, - ExceptionSymbolProvider ESP) { +void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) { if (!shouldEmitCFI) return; @@ -141,14 +119,11 @@ void DwarfCFIException::beginFragment(const MachineBasicBlock *MBB, if (!shouldEmitPersonality) return; - auto &F = MBB->getParent()->getFunction(); - auto *P = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()); + auto &F = MBB.getParent()->getFunction(); + auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts()); assert(P && "Expected personality function"); - - // If we are forced to emit this personality, make sure to record - // it because it might not appear in any landingpad - if (forceEmitPersonality) - MMI->addPersonality(P); + // Record the personality function. + addPersonality(P); const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned PerEncoding = TLOF.getPersonalityEncoding(); @@ -157,7 +132,13 @@ void DwarfCFIException::beginFragment(const MachineBasicBlock *MBB, // Provide LSDA information. if (shouldEmitLSDA) - Asm->OutStreamer->emitCFILsda(ESP(Asm, MBB), TLOF.getLSDAEncoding()); + Asm->OutStreamer->emitCFILsda(Asm->getMBBExceptionSym(MBB), + TLOF.getLSDAEncoding()); +} + +void DwarfCFIException::endBasicBlockSection(const MachineBasicBlock &MBB) { + if (shouldEmitCFI) + Asm->OutStreamer->emitCFIEndProc(); } /// endFunction - Gather and emit post-function exception information. @@ -168,12 +149,3 @@ void DwarfCFIException::endFunction(const MachineFunction *MF) { emitExceptionTable(); } - -void DwarfCFIException::beginBasicBlock(const MachineBasicBlock &MBB) { - beginFragment(&MBB, getExceptionSym); -} - -void DwarfCFIException::endBasicBlock(const MachineBasicBlock &MBB) { - if (shouldEmitCFI) - Asm->OutStreamer->emitCFIEndProc(); -} |
