@@ -561,11 +561,11 @@ bool AsmPrinter::doInitialization(Module &M) {
561
561
if (MAI->doesSupportDebugInformation ()) {
562
562
bool EmitCodeView = M.getCodeViewFlag ();
563
563
if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
564
- DebugHandlers .push_back (std::make_unique<CodeViewDebug>(this ));
564
+ Handlers .push_back (std::make_unique<CodeViewDebug>(this ));
565
565
if (!EmitCodeView || M.getDwarfVersion ()) {
566
566
if (hasDebugInfo ()) {
567
567
DD = new DwarfDebug (this );
568
- DebugHandlers .push_back (std::unique_ptr<DwarfDebug>(DD));
568
+ Handlers .push_back (std::unique_ptr<DwarfDebug>(DD));
569
569
}
570
570
}
571
571
}
@@ -632,12 +632,12 @@ bool AsmPrinter::doInitialization(Module &M) {
632
632
633
633
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
634
634
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 ));
636
636
637
- for (auto &Handler : DebugHandlers)
638
- Handler->beginModule (&M);
639
637
for (auto &Handler : Handlers)
640
638
Handler->beginModule (&M);
639
+ for (auto &Handler : EHHandlers)
640
+ Handler->beginModule (&M);
641
641
642
642
return false ;
643
643
}
@@ -784,7 +784,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
784
784
// sections and expected to be contiguous (e.g. ObjC metadata).
785
785
const Align Alignment = getGVAlignment (GV, DL);
786
786
787
- for (auto &Handler : DebugHandlers )
787
+ for (auto &Handler : Handlers )
788
788
Handler->setSymbolSize (GVSym, Size);
789
789
790
790
// Handle common symbols
@@ -1054,14 +1054,14 @@ void AsmPrinter::emitFunctionHeader() {
1054
1054
}
1055
1055
1056
1056
// Emit pre-function debug and/or EH information.
1057
- for (auto &Handler : DebugHandlers ) {
1057
+ for (auto &Handler : Handlers ) {
1058
1058
Handler->beginFunction (MF);
1059
1059
Handler->beginBasicBlockSection (MF->front ());
1060
1060
}
1061
- for (auto &Handler : Handlers)
1061
+ for (auto &Handler : EHHandlers) {
1062
1062
Handler->beginFunction (MF);
1063
- for (auto &Handler : Handlers)
1064
1063
Handler->beginBasicBlockSection (MF->front ());
1064
+ }
1065
1065
1066
1066
// Emit the prologue data.
1067
1067
if (F.hasPrologueData ())
@@ -1836,7 +1836,7 @@ void AsmPrinter::emitFunctionBody() {
1836
1836
if (MDNode *MD = MI.getPCSections ())
1837
1837
emitPCSectionsLabel (*MF, *MD);
1838
1838
1839
- for (auto &Handler : DebugHandlers )
1839
+ for (auto &Handler : Handlers )
1840
1840
Handler->beginInstruction (&MI);
1841
1841
1842
1842
if (isVerbose ())
@@ -1952,7 +1952,7 @@ void AsmPrinter::emitFunctionBody() {
1952
1952
if (MCSymbol *S = MI.getPostInstrSymbol ())
1953
1953
OutStreamer->emitLabel (S);
1954
1954
1955
- for (auto &Handler : DebugHandlers )
1955
+ for (auto &Handler : Handlers )
1956
1956
Handler->endInstruction ();
1957
1957
}
1958
1958
@@ -2089,24 +2089,26 @@ void AsmPrinter::emitFunctionBody() {
2089
2089
// Call endBasicBlockSection on the last block now, if it wasn't already
2090
2090
// called.
2091
2091
if (!MF->back ().isEndSection ()) {
2092
- for (auto &Handler : DebugHandlers)
2093
- Handler->endBasicBlockSection (MF->back ());
2094
2092
for (auto &Handler : Handlers)
2095
2093
Handler->endBasicBlockSection (MF->back ());
2094
+ for (auto &Handler : EHHandlers)
2095
+ Handler->endBasicBlockSection (MF->back ());
2096
2096
}
2097
2097
for (auto &Handler : Handlers)
2098
2098
Handler->markFunctionEnd ();
2099
+ for (auto &Handler : EHHandlers)
2100
+ Handler->markFunctionEnd ();
2099
2101
// Update the end label of the entry block's section.
2100
2102
MBBSectionRanges[MF->front ().getSectionID ()].EndLabel = CurrentFnEnd;
2101
2103
2102
2104
// Print out jump tables referenced by the function.
2103
2105
emitJumpTableInfo ();
2104
2106
2105
2107
// Emit post-function debug and/or EH information.
2106
- for (auto &Handler : DebugHandlers)
2107
- Handler->endFunction (MF);
2108
2108
for (auto &Handler : Handlers)
2109
2109
Handler->endFunction (MF);
2110
+ for (auto &Handler : EHHandlers)
2111
+ Handler->endFunction (MF);
2110
2112
2111
2113
// Emit section containing BB address offsets and their metadata, when
2112
2114
// BB labels are requested for this function. Skip empty functions.
@@ -2583,17 +2585,16 @@ bool AsmPrinter::doFinalization(Module &M) {
2583
2585
emitGlobalIFunc (M, IFunc);
2584
2586
2585
2587
// Finalize debug and EH information.
2586
- for (auto &Handler : DebugHandlers)
2587
- Handler->endModule ();
2588
2588
for (auto &Handler : Handlers)
2589
2589
Handler->endModule ();
2590
+ for (auto &Handler : EHHandlers)
2591
+ Handler->endModule ();
2590
2592
2591
2593
// This deletes all the ephemeral handlers that AsmPrinter added, while
2592
2594
// keeping all the user-added handlers alive until the AsmPrinter is
2593
2595
// destroyed.
2596
+ EHHandlers.clear ();
2594
2597
Handlers.erase (Handlers.begin () + NumUserHandlers, Handlers.end ());
2595
- DebugHandlers.erase (DebugHandlers.begin () + NumUserDebugHandlers,
2596
- DebugHandlers.end ());
2597
2598
DD = nullptr ;
2598
2599
2599
2600
// If the target wants to know about weak references, print them all.
@@ -4196,6 +4197,10 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4196
4197
Handler->endFunclet ();
4197
4198
Handler->beginFunclet (MBB);
4198
4199
}
4200
+ for (auto &Handler : EHHandlers) {
4201
+ Handler->endFunclet ();
4202
+ Handler->beginFunclet (MBB);
4203
+ }
4199
4204
}
4200
4205
4201
4206
// Switch to a new section if this basic block must begin a section. The
@@ -4208,7 +4213,7 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4208
4213
CurrentSectionBeginSym = MBB.getSymbol ();
4209
4214
}
4210
4215
4211
- for (auto &Handler : DebugHandlers )
4216
+ for (auto &Handler : Handlers )
4212
4217
Handler->beginCodeAlignment (MBB);
4213
4218
4214
4219
// Emit an alignment directive for this block, if needed.
@@ -4268,21 +4273,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4268
4273
// if it begins a section (Entry block call is handled separately, next to
4269
4274
// beginFunction).
4270
4275
if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4271
- for (auto &Handler : DebugHandlers)
4272
- Handler->beginBasicBlockSection (MBB);
4273
4276
for (auto &Handler : Handlers)
4274
4277
Handler->beginBasicBlockSection (MBB);
4278
+ for (auto &Handler : EHHandlers)
4279
+ Handler->beginBasicBlockSection (MBB);
4275
4280
}
4276
4281
}
4277
4282
4278
4283
void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
4279
4284
// Check if CFI information needs to be updated for this MBB with basic block
4280
4285
// sections.
4281
4286
if (MBB.isEndSection ()) {
4282
- for (auto &Handler : DebugHandlers)
4283
- Handler->endBasicBlockSection (MBB);
4284
4287
for (auto &Handler : Handlers)
4285
4288
Handler->endBasicBlockSection (MBB);
4289
+ for (auto &Handler : EHHandlers)
4290
+ Handler->endBasicBlockSection (MBB);
4286
4291
}
4287
4292
}
4288
4293
@@ -4415,12 +4420,7 @@ void AsmPrinter::addAsmPrinterHandler(
4415
4420
NumUserHandlers++;
4416
4421
}
4417
4422
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.
4424
4424
AsmPrinterHandler::~AsmPrinterHandler () = default ;
4425
4425
4426
4426
void AsmPrinterHandler::markFunctionEnd () {}
0 commit comments