@@ -561,11 +561,11 @@ bool AsmPrinter::doInitialization(Module &M) {
561561 if (MAI->doesSupportDebugInformation ()) {
562562 bool EmitCodeView = M.getCodeViewFlag ();
563563 if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
564- DebugHandlers .push_back (std::make_unique<CodeViewDebug>(this ));
564+ Handlers .push_back (std::make_unique<CodeViewDebug>(this ));
565565 if (!EmitCodeView || M.getDwarfVersion ()) {
566566 if (hasDebugInfo ()) {
567567 DD = new DwarfDebug (this );
568- DebugHandlers .push_back (std::unique_ptr<DwarfDebug>(DD));
568+ Handlers .push_back (std::unique_ptr<DwarfDebug>(DD));
569569 }
570570 }
571571 }
@@ -632,12 +632,12 @@ bool AsmPrinter::doInitialization(Module &M) {
632632
633633 // Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
634634 if (mdconst::extract_or_null<ConstantInt>(M.getModuleFlag (" cfguard" )))
635- Handlers .push_back (std::make_unique<WinCFGuard>(this ));
635+ EHHandlers .push_back (std::make_unique<WinCFGuard>(this ));
636636
637- for (auto &Handler : DebugHandlers)
638- Handler->beginModule (&M);
639637 for (auto &Handler : Handlers)
640638 Handler->beginModule (&M);
639+ for (auto &Handler : EHHandlers)
640+ Handler->beginModule (&M);
641641
642642 return false ;
643643}
@@ -784,7 +784,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
784784 // sections and expected to be contiguous (e.g. ObjC metadata).
785785 const Align Alignment = getGVAlignment (GV, DL);
786786
787- for (auto &Handler : DebugHandlers )
787+ for (auto &Handler : Handlers )
788788 Handler->setSymbolSize (GVSym, Size);
789789
790790 // Handle common symbols
@@ -1054,14 +1054,14 @@ void AsmPrinter::emitFunctionHeader() {
10541054 }
10551055
10561056 // Emit pre-function debug and/or EH information.
1057- for (auto &Handler : DebugHandlers ) {
1057+ for (auto &Handler : Handlers ) {
10581058 Handler->beginFunction (MF);
10591059 Handler->beginBasicBlockSection (MF->front ());
10601060 }
1061- for (auto &Handler : Handlers)
1061+ for (auto &Handler : EHHandlers) {
10621062 Handler->beginFunction (MF);
1063- for (auto &Handler : Handlers)
10641063 Handler->beginBasicBlockSection (MF->front ());
1064+ }
10651065
10661066 // Emit the prologue data.
10671067 if (F.hasPrologueData ())
@@ -1836,7 +1836,7 @@ void AsmPrinter::emitFunctionBody() {
18361836 if (MDNode *MD = MI.getPCSections ())
18371837 emitPCSectionsLabel (*MF, *MD);
18381838
1839- for (auto &Handler : DebugHandlers )
1839+ for (auto &Handler : Handlers )
18401840 Handler->beginInstruction (&MI);
18411841
18421842 if (isVerbose ())
@@ -1952,7 +1952,7 @@ void AsmPrinter::emitFunctionBody() {
19521952 if (MCSymbol *S = MI.getPostInstrSymbol ())
19531953 OutStreamer->emitLabel (S);
19541954
1955- for (auto &Handler : DebugHandlers )
1955+ for (auto &Handler : Handlers )
19561956 Handler->endInstruction ();
19571957 }
19581958
@@ -2089,24 +2089,26 @@ void AsmPrinter::emitFunctionBody() {
20892089 // Call endBasicBlockSection on the last block now, if it wasn't already
20902090 // called.
20912091 if (!MF->back ().isEndSection ()) {
2092- for (auto &Handler : DebugHandlers)
2093- Handler->endBasicBlockSection (MF->back ());
20942092 for (auto &Handler : Handlers)
20952093 Handler->endBasicBlockSection (MF->back ());
2094+ for (auto &Handler : EHHandlers)
2095+ Handler->endBasicBlockSection (MF->back ());
20962096 }
20972097 for (auto &Handler : Handlers)
20982098 Handler->markFunctionEnd ();
2099+ for (auto &Handler : EHHandlers)
2100+ Handler->markFunctionEnd ();
20992101 // Update the end label of the entry block's section.
21002102 MBBSectionRanges[MF->front ().getSectionID ()].EndLabel = CurrentFnEnd;
21012103
21022104 // Print out jump tables referenced by the function.
21032105 emitJumpTableInfo ();
21042106
21052107 // Emit post-function debug and/or EH information.
2106- for (auto &Handler : DebugHandlers)
2107- Handler->endFunction (MF);
21082108 for (auto &Handler : Handlers)
21092109 Handler->endFunction (MF);
2110+ for (auto &Handler : EHHandlers)
2111+ Handler->endFunction (MF);
21102112
21112113 // Emit section containing BB address offsets and their metadata, when
21122114 // BB labels are requested for this function. Skip empty functions.
@@ -2583,17 +2585,16 @@ bool AsmPrinter::doFinalization(Module &M) {
25832585 emitGlobalIFunc (M, IFunc);
25842586
25852587 // Finalize debug and EH information.
2586- for (auto &Handler : DebugHandlers)
2587- Handler->endModule ();
25882588 for (auto &Handler : Handlers)
25892589 Handler->endModule ();
2590+ for (auto &Handler : EHHandlers)
2591+ Handler->endModule ();
25902592
25912593 // This deletes all the ephemeral handlers that AsmPrinter added, while
25922594 // keeping all the user-added handlers alive until the AsmPrinter is
25932595 // destroyed.
2596+ EHHandlers.clear ();
25942597 Handlers.erase (Handlers.begin () + NumUserHandlers, Handlers.end ());
2595- DebugHandlers.erase (DebugHandlers.begin () + NumUserDebugHandlers,
2596- DebugHandlers.end ());
25972598 DD = nullptr ;
25982599
25992600 // If the target wants to know about weak references, print them all.
@@ -4196,6 +4197,10 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
41964197 Handler->endFunclet ();
41974198 Handler->beginFunclet (MBB);
41984199 }
4200+ for (auto &Handler : EHHandlers) {
4201+ Handler->endFunclet ();
4202+ Handler->beginFunclet (MBB);
4203+ }
41994204 }
42004205
42014206 // Switch to a new section if this basic block must begin a section. The
@@ -4208,7 +4213,7 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
42084213 CurrentSectionBeginSym = MBB.getSymbol ();
42094214 }
42104215
4211- for (auto &Handler : DebugHandlers )
4216+ for (auto &Handler : Handlers )
42124217 Handler->beginCodeAlignment (MBB);
42134218
42144219 // Emit an alignment directive for this block, if needed.
@@ -4268,21 +4273,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
42684273 // if it begins a section (Entry block call is handled separately, next to
42694274 // beginFunction).
42704275 if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4271- for (auto &Handler : DebugHandlers)
4272- Handler->beginBasicBlockSection (MBB);
42734276 for (auto &Handler : Handlers)
42744277 Handler->beginBasicBlockSection (MBB);
4278+ for (auto &Handler : EHHandlers)
4279+ Handler->beginBasicBlockSection (MBB);
42754280 }
42764281}
42774282
42784283void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
42794284 // Check if CFI information needs to be updated for this MBB with basic block
42804285 // sections.
42814286 if (MBB.isEndSection ()) {
4282- for (auto &Handler : DebugHandlers)
4283- Handler->endBasicBlockSection (MBB);
42844287 for (auto &Handler : Handlers)
42854288 Handler->endBasicBlockSection (MBB);
4289+ for (auto &Handler : EHHandlers)
4290+ Handler->endBasicBlockSection (MBB);
42864291 }
42874292}
42884293
@@ -4415,12 +4420,7 @@ void AsmPrinter::addAsmPrinterHandler(
44154420 NumUserHandlers++;
44164421}
44174422
4418- void AsmPrinter::addDebugHandler (std::unique_ptr<DebugHandlerBase> Handler) {
4419- DebugHandlers.insert (DebugHandlers.begin (), std::move (Handler));
4420- NumUserDebugHandlers++;
4421- }
4422-
4423- // / Pin vtable to this file.
4423+ // / Pin vtables to this file.
44244424AsmPrinterHandler::~AsmPrinterHandler () = default ;
44254425
44264426void AsmPrinterHandler::markFunctionEnd () {}
0 commit comments