@@ -392,7 +392,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
392
392
}
393
393
394
394
AsmPrinter::~AsmPrinter () {
395
- assert (!DD && DebugHandlers .size () == NumUserDebugHandlers &&
395
+ assert (!DD && Handlers .size () == NumUserHandlers &&
396
396
" Debug/EH info didn't get finalized" );
397
397
}
398
398
@@ -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,12 +2089,12 @@ 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
- for (auto &Handler : Handlers )
2097
+ for (auto &Handler : EHHandlers )
2098
2098
Handler->markFunctionEnd ();
2099
2099
// Update the end label of the entry block's section.
2100
2100
MBBSectionRanges[MF->front ().getSectionID ()].EndLabel = CurrentFnEnd;
@@ -2103,10 +2103,10 @@ void AsmPrinter::emitFunctionBody() {
2103
2103
emitJumpTableInfo ();
2104
2104
2105
2105
// Emit post-function debug and/or EH information.
2106
- for (auto &Handler : DebugHandlers)
2107
- Handler->endFunction (MF);
2108
2106
for (auto &Handler : Handlers)
2109
2107
Handler->endFunction (MF);
2108
+ for (auto &Handler : EHHandlers)
2109
+ Handler->endFunction (MF);
2110
2110
2111
2111
// Emit section containing BB address offsets and their metadata, when
2112
2112
// BB labels are requested for this function. Skip empty functions.
@@ -2583,17 +2583,16 @@ bool AsmPrinter::doFinalization(Module &M) {
2583
2583
emitGlobalIFunc (M, IFunc);
2584
2584
2585
2585
// Finalize debug and EH information.
2586
- for (auto &Handler : DebugHandlers)
2587
- Handler->endModule ();
2588
2586
for (auto &Handler : Handlers)
2589
2587
Handler->endModule ();
2588
+ for (auto &Handler : EHHandlers)
2589
+ Handler->endModule ();
2590
2590
2591
2591
// This deletes all the ephemeral handlers that AsmPrinter added, while
2592
2592
// keeping all the user-added handlers alive until the AsmPrinter is
2593
2593
// destroyed.
2594
- Handlers.clear ();
2595
- DebugHandlers.erase (DebugHandlers.begin () + NumUserDebugHandlers,
2596
- DebugHandlers.end ());
2594
+ EHHandlers.clear ();
2595
+ Handlers.erase (Handlers.begin () + NumUserHandlers, Handlers.end ());
2597
2596
DD = nullptr ;
2598
2597
2599
2598
// If the target wants to know about weak references, print them all.
@@ -4196,6 +4195,10 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4196
4195
Handler->endFunclet ();
4197
4196
Handler->beginFunclet (MBB);
4198
4197
}
4198
+ for (auto &Handler : EHHandlers) {
4199
+ Handler->endFunclet ();
4200
+ Handler->beginFunclet (MBB);
4201
+ }
4199
4202
}
4200
4203
4201
4204
// Switch to a new section if this basic block must begin a section. The
@@ -4208,7 +4211,7 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4208
4211
CurrentSectionBeginSym = MBB.getSymbol ();
4209
4212
}
4210
4213
4211
- for (auto &Handler : DebugHandlers )
4214
+ for (auto &Handler : Handlers )
4212
4215
Handler->beginCodeAlignment (MBB);
4213
4216
4214
4217
// Emit an alignment directive for this block, if needed.
@@ -4268,21 +4271,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4268
4271
// if it begins a section (Entry block call is handled separately, next to
4269
4272
// beginFunction).
4270
4273
if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4271
- for (auto &Handler : DebugHandlers)
4272
- Handler->beginBasicBlockSection (MBB);
4273
4274
for (auto &Handler : Handlers)
4274
4275
Handler->beginBasicBlockSection (MBB);
4276
+ for (auto &Handler : EHHandlers)
4277
+ Handler->beginBasicBlockSection (MBB);
4275
4278
}
4276
4279
}
4277
4280
4278
4281
void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
4279
4282
// Check if CFI information needs to be updated for this MBB with basic block
4280
4283
// sections.
4281
4284
if (MBB.isEndSection ()) {
4282
- for (auto &Handler : DebugHandlers)
4283
- Handler->endBasicBlockSection (MBB);
4284
4285
for (auto &Handler : Handlers)
4285
4286
Handler->endBasicBlockSection (MBB);
4287
+ for (auto &Handler : EHHandlers)
4288
+ Handler->endBasicBlockSection (MBB);
4286
4289
}
4287
4290
}
4288
4291
@@ -4411,15 +4414,14 @@ void AsmPrinter::emitStackMaps() {
4411
4414
4412
4415
void AsmPrinter::addAsmPrinterHandler (
4413
4416
std::unique_ptr<AsmPrinterHandler> Handler) {
4414
- DebugHandlers .insert (DebugHandlers .begin (), std::move (Handler));
4415
- NumUserDebugHandlers ++;
4417
+ Handlers .insert (Handlers .begin (), std::move (Handler));
4418
+ NumUserHandlers ++;
4416
4419
}
4417
4420
4418
4421
// / Pin vtables to this file.
4419
- AsmBasicPrinterHandler::~AsmBasicPrinterHandler () = default ;
4420
4422
AsmPrinterHandler::~AsmPrinterHandler () = default ;
4421
4423
4422
- void AsmBasicPrinterHandler ::markFunctionEnd () {}
4424
+ void AsmPrinterHandler ::markFunctionEnd () {}
4423
4425
4424
4426
// In the binary's "xray_instr_map" section, an array of these function entries
4425
4427
// describes each instrumentation point. When XRay patches your code, the index
0 commit comments