@@ -539,12 +539,12 @@ bool AsmPrinter::doInitialization(Module &M) {
539539 if (MAI->doesSupportDebugInformation ()) {
540540 bool EmitCodeView = M.getCodeViewFlag ();
541541 if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
542- DebugHandlers .push_back (std::make_unique<CodeViewDebug>(this ));
542+ Handlers .push_back (std::make_unique<CodeViewDebug>(this ));
543543 if (!EmitCodeView || M.getDwarfVersion ()) {
544544 assert (MMI && " MMI could not be nullptr here!" );
545545 if (MMI->hasDebugInfo ()) {
546546 DD = new DwarfDebug (this );
547- DebugHandlers .push_back (std::unique_ptr<DwarfDebug>(DD));
547+ Handlers .push_back (std::unique_ptr<DwarfDebug>(DD));
548548 }
549549 }
550550 }
@@ -611,12 +611,12 @@ bool AsmPrinter::doInitialization(Module &M) {
611611
612612 // Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
613613 if (mdconst::extract_or_null<ConstantInt>(M.getModuleFlag (" cfguard" )))
614- Handlers .push_back (std::make_unique<WinCFGuard>(this ));
614+ EHHandlers .push_back (std::make_unique<WinCFGuard>(this ));
615615
616- for (auto &Handler : DebugHandlers)
617- Handler->beginModule (&M);
618616 for (auto &Handler : Handlers)
619617 Handler->beginModule (&M);
618+ for (auto &Handler : EHHandlers)
619+ Handler->beginModule (&M);
620620
621621 return false ;
622622}
@@ -763,7 +763,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
763763 // sections and expected to be contiguous (e.g. ObjC metadata).
764764 const Align Alignment = getGVAlignment (GV, DL);
765765
766- for (auto &Handler : DebugHandlers )
766+ for (auto &Handler : Handlers )
767767 Handler->setSymbolSize (GVSym, Size);
768768
769769 // Handle common symbols
@@ -1035,14 +1035,14 @@ void AsmPrinter::emitFunctionHeader() {
10351035 }
10361036
10371037 // Emit pre-function debug and/or EH information.
1038- for (auto &Handler : DebugHandlers ) {
1038+ for (auto &Handler : Handlers ) {
10391039 Handler->beginFunction (MF);
10401040 Handler->beginBasicBlockSection (MF->front ());
10411041 }
1042- for (auto &Handler : Handlers)
1042+ for (auto &Handler : EHHandlers) {
10431043 Handler->beginFunction (MF);
1044- for (auto &Handler : Handlers)
10451044 Handler->beginBasicBlockSection (MF->front ());
1045+ }
10461046
10471047 // Emit the prologue data.
10481048 if (F.hasPrologueData ())
@@ -1737,7 +1737,7 @@ void AsmPrinter::emitFunctionBody() {
17371737 if (MDNode *MD = MI.getPCSections ())
17381738 emitPCSectionsLabel (*MF, *MD);
17391739
1740- for (auto &Handler : DebugHandlers )
1740+ for (auto &Handler : Handlers )
17411741 Handler->beginInstruction (&MI);
17421742
17431743 if (isVerbose ())
@@ -1832,7 +1832,7 @@ void AsmPrinter::emitFunctionBody() {
18321832 if (MCSymbol *S = MI.getPostInstrSymbol ())
18331833 OutStreamer->emitLabel (S);
18341834
1835- for (auto &Handler : DebugHandlers )
1835+ for (auto &Handler : Handlers )
18361836 Handler->endInstruction ();
18371837 }
18381838
@@ -1966,13 +1966,15 @@ void AsmPrinter::emitFunctionBody() {
19661966 // Call endBasicBlockSection on the last block now, if it wasn't already
19671967 // called.
19681968 if (!MF->back ().isEndSection ()) {
1969- for (auto &Handler : DebugHandlers)
1970- Handler->endBasicBlockSection (MF->back ());
19711969 for (auto &Handler : Handlers)
19721970 Handler->endBasicBlockSection (MF->back ());
1971+ for (auto &Handler : EHHandlers)
1972+ Handler->endBasicBlockSection (MF->back ());
19731973 }
19741974 for (auto &Handler : Handlers)
19751975 Handler->markFunctionEnd ();
1976+ for (auto &Handler : EHHandlers)
1977+ Handler->markFunctionEnd ();
19761978
19771979 assert (!MBBSectionRanges.contains (MF->front ().getSectionID ()) &&
19781980 " Overwrite section range" );
@@ -1983,10 +1985,10 @@ void AsmPrinter::emitFunctionBody() {
19831985 emitJumpTableInfo ();
19841986
19851987 // Emit post-function debug and/or EH information.
1986- for (auto &Handler : DebugHandlers)
1987- Handler->endFunction (MF);
19881988 for (auto &Handler : Handlers)
19891989 Handler->endFunction (MF);
1990+ for (auto &Handler : EHHandlers)
1991+ Handler->endFunction (MF);
19901992
19911993 // Emit section containing BB address offsets and their metadata, when
19921994 // BB labels are requested for this function. Skip empty functions.
@@ -2425,17 +2427,16 @@ bool AsmPrinter::doFinalization(Module &M) {
24252427 emitGlobalIFunc (M, IFunc);
24262428
24272429 // Finalize debug and EH information.
2428- for (auto &Handler : DebugHandlers)
2429- Handler->endModule ();
24302430 for (auto &Handler : Handlers)
24312431 Handler->endModule ();
2432+ for (auto &Handler : EHHandlers)
2433+ Handler->endModule ();
24322434
24332435 // This deletes all the ephemeral handlers that AsmPrinter added, while
24342436 // keeping all the user-added handlers alive until the AsmPrinter is
24352437 // destroyed.
2438+ EHHandlers.clear ();
24362439 Handlers.erase (Handlers.begin () + NumUserHandlers, Handlers.end ());
2437- DebugHandlers.erase (DebugHandlers.begin () + NumUserDebugHandlers,
2438- DebugHandlers.end ());
24392440 DD = nullptr ;
24402441
24412442 // If the target wants to know about weak references, print them all.
@@ -3957,6 +3958,10 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
39573958 Handler->endFunclet ();
39583959 Handler->beginFunclet (MBB);
39593960 }
3961+ for (auto &Handler : EHHandlers) {
3962+ Handler->endFunclet ();
3963+ Handler->beginFunclet (MBB);
3964+ }
39603965 }
39613966
39623967 // Switch to a new section if this basic block must begin a section. The
@@ -4026,21 +4031,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
40264031 // if it begins a section (Entry block call is handled separately, next to
40274032 // beginFunction).
40284033 if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4029- for (auto &Handler : DebugHandlers)
4030- Handler->beginBasicBlockSection (MBB);
40314034 for (auto &Handler : Handlers)
40324035 Handler->beginBasicBlockSection (MBB);
4036+ for (auto &Handler : EHHandlers)
4037+ Handler->beginBasicBlockSection (MBB);
40334038 }
40344039}
40354040
40364041void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
40374042 // Check if CFI information needs to be updated for this MBB with basic block
40384043 // sections.
40394044 if (MBB.isEndSection ()) {
4040- for (auto &Handler : DebugHandlers)
4041- Handler->endBasicBlockSection (MBB);
40424045 for (auto &Handler : Handlers)
40434046 Handler->endBasicBlockSection (MBB);
4047+ for (auto &Handler : EHHandlers)
4048+ Handler->endBasicBlockSection (MBB);
40444049 }
40454050}
40464051
@@ -4174,12 +4179,7 @@ void AsmPrinter::addAsmPrinterHandler(
41744179 NumUserHandlers++;
41754180}
41764181
4177- void AsmPrinter::addDebugHandler (std::unique_ptr<DebugHandlerBase> Handler) {
4178- DebugHandlers.insert (DebugHandlers.begin (), std::move (Handler));
4179- NumUserDebugHandlers++;
4180- }
4181-
4182- // / Pin vtable to this file.
4182+ // / Pin vtables to this file.
41834183AsmPrinterHandler::~AsmPrinterHandler () = default ;
41844184
41854185void AsmPrinterHandler::markFunctionEnd () {}
0 commit comments