@@ -539,12 +539,12 @@ bool AsmPrinter::doInitialization(Module &M) {
539
539
if (MAI->doesSupportDebugInformation ()) {
540
540
bool EmitCodeView = M.getCodeViewFlag ();
541
541
if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
542
- DebugHandlers .push_back (std::make_unique<CodeViewDebug>(this ));
542
+ Handlers .push_back (std::make_unique<CodeViewDebug>(this ));
543
543
if (!EmitCodeView || M.getDwarfVersion ()) {
544
544
assert (MMI && " MMI could not be nullptr here!" );
545
545
if (MMI->hasDebugInfo ()) {
546
546
DD = new DwarfDebug (this );
547
- DebugHandlers .push_back (std::unique_ptr<DwarfDebug>(DD));
547
+ Handlers .push_back (std::unique_ptr<DwarfDebug>(DD));
548
548
}
549
549
}
550
550
}
@@ -611,12 +611,12 @@ bool AsmPrinter::doInitialization(Module &M) {
611
611
612
612
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
613
613
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 ));
615
615
616
- for (auto &Handler : DebugHandlers)
617
- Handler->beginModule (&M);
618
616
for (auto &Handler : Handlers)
619
617
Handler->beginModule (&M);
618
+ for (auto &Handler : EHHandlers)
619
+ Handler->beginModule (&M);
620
620
621
621
return false ;
622
622
}
@@ -763,7 +763,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
763
763
// sections and expected to be contiguous (e.g. ObjC metadata).
764
764
const Align Alignment = getGVAlignment (GV, DL);
765
765
766
- for (auto &Handler : DebugHandlers )
766
+ for (auto &Handler : Handlers )
767
767
Handler->setSymbolSize (GVSym, Size );
768
768
769
769
// Handle common symbols
@@ -1035,14 +1035,14 @@ void AsmPrinter::emitFunctionHeader() {
1035
1035
}
1036
1036
1037
1037
// Emit pre-function debug and/or EH information.
1038
- for (auto &Handler : DebugHandlers ) {
1038
+ for (auto &Handler : Handlers ) {
1039
1039
Handler->beginFunction (MF);
1040
1040
Handler->beginBasicBlockSection (MF->front ());
1041
1041
}
1042
- for (auto &Handler : Handlers)
1042
+ for (auto &Handler : EHHandlers) {
1043
1043
Handler->beginFunction (MF);
1044
- for (auto &Handler : Handlers)
1045
1044
Handler->beginBasicBlockSection (MF->front ());
1045
+ }
1046
1046
1047
1047
// Emit the prologue data.
1048
1048
if (F.hasPrologueData ())
@@ -1737,7 +1737,7 @@ void AsmPrinter::emitFunctionBody() {
1737
1737
if (MDNode *MD = MI.getPCSections ())
1738
1738
emitPCSectionsLabel (*MF, *MD);
1739
1739
1740
- for (auto &Handler : DebugHandlers )
1740
+ for (auto &Handler : Handlers )
1741
1741
Handler->beginInstruction (&MI);
1742
1742
1743
1743
if (isVerbose ())
@@ -1832,7 +1832,7 @@ void AsmPrinter::emitFunctionBody() {
1832
1832
if (MCSymbol *S = MI.getPostInstrSymbol ())
1833
1833
OutStreamer->emitLabel (S);
1834
1834
1835
- for (auto &Handler : DebugHandlers )
1835
+ for (auto &Handler : Handlers )
1836
1836
Handler->endInstruction ();
1837
1837
}
1838
1838
@@ -1966,13 +1966,15 @@ void AsmPrinter::emitFunctionBody() {
1966
1966
// Call endBasicBlockSection on the last block now, if it wasn't already
1967
1967
// called.
1968
1968
if (!MF->back ().isEndSection ()) {
1969
- for (auto &Handler : DebugHandlers)
1970
- Handler->endBasicBlockSection (MF->back ());
1971
1969
for (auto &Handler : Handlers)
1972
1970
Handler->endBasicBlockSection (MF->back ());
1971
+ for (auto &Handler : EHHandlers)
1972
+ Handler->endBasicBlockSection (MF->back ());
1973
1973
}
1974
1974
for (auto &Handler : Handlers)
1975
1975
Handler->markFunctionEnd ();
1976
+ for (auto &Handler : EHHandlers)
1977
+ Handler->markFunctionEnd ();
1976
1978
1977
1979
assert (!MBBSectionRanges.contains (MF->front ().getSectionID ()) &&
1978
1980
" Overwrite section range" );
@@ -1983,10 +1985,10 @@ void AsmPrinter::emitFunctionBody() {
1983
1985
emitJumpTableInfo ();
1984
1986
1985
1987
// Emit post-function debug and/or EH information.
1986
- for (auto &Handler : DebugHandlers)
1987
- Handler->endFunction (MF);
1988
1988
for (auto &Handler : Handlers)
1989
1989
Handler->endFunction (MF);
1990
+ for (auto &Handler : EHHandlers)
1991
+ Handler->endFunction (MF);
1990
1992
1991
1993
// Emit section containing BB address offsets and their metadata, when
1992
1994
// BB labels are requested for this function. Skip empty functions.
@@ -2425,17 +2427,16 @@ bool AsmPrinter::doFinalization(Module &M) {
2425
2427
emitGlobalIFunc (M, IFunc);
2426
2428
2427
2429
// Finalize debug and EH information.
2428
- for (auto &Handler : DebugHandlers)
2429
- Handler->endModule ();
2430
2430
for (auto &Handler : Handlers)
2431
2431
Handler->endModule ();
2432
+ for (auto &Handler : EHHandlers)
2433
+ Handler->endModule ();
2432
2434
2433
2435
// This deletes all the ephemeral handlers that AsmPrinter added, while
2434
2436
// keeping all the user-added handlers alive until the AsmPrinter is
2435
2437
// destroyed.
2438
+ EHHandlers.clear ();
2436
2439
Handlers.erase (Handlers.begin () + NumUserHandlers, Handlers.end ());
2437
- DebugHandlers.erase (DebugHandlers.begin () + NumUserDebugHandlers,
2438
- DebugHandlers.end ());
2439
2440
DD = nullptr ;
2440
2441
2441
2442
// If the target wants to know about weak references, print them all.
@@ -3957,6 +3958,10 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
3957
3958
Handler->endFunclet ();
3958
3959
Handler->beginFunclet (MBB);
3959
3960
}
3961
+ for (auto &Handler : EHHandlers) {
3962
+ Handler->endFunclet ();
3963
+ Handler->beginFunclet (MBB);
3964
+ }
3960
3965
}
3961
3966
3962
3967
// Switch to a new section if this basic block must begin a section. The
@@ -4026,21 +4031,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4026
4031
// if it begins a section (Entry block call is handled separately, next to
4027
4032
// beginFunction).
4028
4033
if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4029
- for (auto &Handler : DebugHandlers)
4030
- Handler->beginBasicBlockSection (MBB);
4031
4034
for (auto &Handler : Handlers)
4032
4035
Handler->beginBasicBlockSection (MBB);
4036
+ for (auto &Handler : EHHandlers)
4037
+ Handler->beginBasicBlockSection (MBB);
4033
4038
}
4034
4039
}
4035
4040
4036
4041
void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
4037
4042
// Check if CFI information needs to be updated for this MBB with basic block
4038
4043
// sections.
4039
4044
if (MBB.isEndSection ()) {
4040
- for (auto &Handler : DebugHandlers)
4041
- Handler->endBasicBlockSection (MBB);
4042
4045
for (auto &Handler : Handlers)
4043
4046
Handler->endBasicBlockSection (MBB);
4047
+ for (auto &Handler : EHHandlers)
4048
+ Handler->endBasicBlockSection (MBB);
4044
4049
}
4045
4050
}
4046
4051
@@ -4174,12 +4179,7 @@ void AsmPrinter::addAsmPrinterHandler(
4174
4179
NumUserHandlers++;
4175
4180
}
4176
4181
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.
4183
4183
AsmPrinterHandler::~AsmPrinterHandler () = default ;
4184
4184
4185
4185
void AsmPrinterHandler::markFunctionEnd () {}
0 commit comments