113
113
#include " llvm/Support/Format.h"
114
114
#include " llvm/Support/MathExtras.h"
115
115
#include " llvm/Support/Path.h"
116
- #include " llvm/Support/Timer.h"
117
116
#include " llvm/Support/VCSRevision.h"
118
117
#include " llvm/Support/raw_ostream.h"
119
118
#include " llvm/Target/TargetLoweringObjectFile.h"
@@ -156,17 +155,6 @@ static cl::bits<PGOMapFeaturesEnum> PgoAnalysisMapFeatures(
156
155
" Enable extended information within the SHT_LLVM_BB_ADDR_MAP that is "
157
156
" extracted from PGO related analysis." ));
158
157
159
- const char DWARFGroupName[] = " dwarf" ;
160
- const char DWARFGroupDescription[] = " DWARF Emission" ;
161
- const char DbgTimerName[] = " emit" ;
162
- const char DbgTimerDescription[] = " Debug Info Emission" ;
163
- const char EHTimerName[] = " write_exception" ;
164
- const char EHTimerDescription[] = " DWARF Exception Writer" ;
165
- const char CFGuardName[] = " Control Flow Guard" ;
166
- const char CFGuardDescription[] = " Control Flow Guard" ;
167
- const char CodeViewLineTablesGroupName[] = " linetables" ;
168
- const char CodeViewLineTablesGroupDescription[] = " CodeView Line Tables" ;
169
-
170
158
STATISTIC (EmittedInsts, " Number of machine instrs printed" );
171
159
172
160
char AsmPrinter::ID = 0 ;
@@ -550,19 +538,13 @@ bool AsmPrinter::doInitialization(Module &M) {
550
538
551
539
if (MAI->doesSupportDebugInformation ()) {
552
540
bool EmitCodeView = M.getCodeViewFlag ();
553
- if (EmitCodeView && TM.getTargetTriple ().isOSWindows ()) {
554
- DebugHandlers.emplace_back (std::make_unique<CodeViewDebug>(this ),
555
- DbgTimerName, DbgTimerDescription,
556
- CodeViewLineTablesGroupName,
557
- CodeViewLineTablesGroupDescription);
558
- }
541
+ if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
542
+ DebugHandlers.push_back (std::make_unique<CodeViewDebug>(this ));
559
543
if (!EmitCodeView || M.getDwarfVersion ()) {
560
544
assert (MMI && " MMI could not be nullptr here!" );
561
545
if (MMI->hasDebugInfo ()) {
562
546
DD = new DwarfDebug (this );
563
- DebugHandlers.emplace_back (std::unique_ptr<DwarfDebug>(DD),
564
- DbgTimerName, DbgTimerDescription,
565
- DWARFGroupName, DWARFGroupDescription);
547
+ DebugHandlers.push_back (std::unique_ptr<DwarfDebug>(DD));
566
548
}
567
549
}
568
550
}
@@ -625,26 +607,16 @@ bool AsmPrinter::doInitialization(Module &M) {
625
607
break ;
626
608
}
627
609
if (ES)
628
- Handlers.emplace_back (std::unique_ptr<EHStreamer>(ES), EHTimerName,
629
- EHTimerDescription, DWARFGroupName,
630
- DWARFGroupDescription);
610
+ Handlers.push_back (std::unique_ptr<EHStreamer>(ES));
631
611
632
612
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
633
613
if (mdconst::extract_or_null<ConstantInt>(M.getModuleFlag (" cfguard" )))
634
- Handlers.emplace_back (std::make_unique<WinCFGuard>(this ), CFGuardName,
635
- CFGuardDescription, DWARFGroupName,
636
- DWARFGroupDescription);
614
+ Handlers.push_back (std::make_unique<WinCFGuard>(this ));
637
615
638
- for (const auto &HI : DebugHandlers) {
639
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
640
- HI.TimerGroupDescription , TimePassesIsEnabled);
641
- HI.Handler ->beginModule (&M);
642
- }
643
- for (const auto &HI : Handlers) {
644
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
645
- HI.TimerGroupDescription , TimePassesIsEnabled);
646
- HI.Handler ->beginModule (&M);
647
- }
616
+ for (auto &Handler : DebugHandlers)
617
+ Handler->beginModule (&M);
618
+ for (auto &Handler : Handlers)
619
+ Handler->beginModule (&M);
648
620
649
621
return false ;
650
622
}
@@ -791,11 +763,8 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
791
763
// sections and expected to be contiguous (e.g. ObjC metadata).
792
764
const Align Alignment = getGVAlignment (GV, DL);
793
765
794
- for (auto &HI : DebugHandlers) {
795
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
796
- HI.TimerGroupDescription , TimePassesIsEnabled);
797
- HI.Handler ->setSymbolSize (GVSym, Size);
798
- }
766
+ for (auto &Handler : DebugHandlers)
767
+ Handler->setSymbolSize (GVSym, Size);
799
768
800
769
// Handle common symbols
801
770
if (GVKind.isCommon ()) {
@@ -1066,22 +1035,14 @@ void AsmPrinter::emitFunctionHeader() {
1066
1035
}
1067
1036
1068
1037
// Emit pre-function debug and/or EH information.
1069
- for (const auto &HI : DebugHandlers) {
1070
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
1071
- HI.TimerGroupDescription , TimePassesIsEnabled);
1072
- HI.Handler ->beginFunction (MF);
1073
- HI.Handler ->beginBasicBlockSection (MF->front ());
1074
- }
1075
- for (const auto &HI : Handlers) {
1076
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
1077
- HI.TimerGroupDescription , TimePassesIsEnabled);
1078
- HI.Handler ->beginFunction (MF);
1079
- }
1080
- for (const auto &HI : Handlers) {
1081
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
1082
- HI.TimerGroupDescription , TimePassesIsEnabled);
1083
- HI.Handler ->beginBasicBlockSection (MF->front ());
1038
+ for (auto &Handler : DebugHandlers) {
1039
+ Handler->beginFunction (MF);
1040
+ Handler->beginBasicBlockSection (MF->front ());
1084
1041
}
1042
+ for (auto &Handler : Handlers)
1043
+ Handler->beginFunction (MF);
1044
+ for (auto &Handler : Handlers)
1045
+ Handler->beginBasicBlockSection (MF->front ());
1085
1046
1086
1047
// Emit the prologue data.
1087
1048
if (F.hasPrologueData ())
@@ -1776,8 +1737,8 @@ void AsmPrinter::emitFunctionBody() {
1776
1737
if (MDNode *MD = MI.getPCSections ())
1777
1738
emitPCSectionsLabel (*MF, *MD);
1778
1739
1779
- for (const auto &HI : DebugHandlers)
1780
- HI. Handler ->beginInstruction (&MI);
1740
+ for (auto &Handler : DebugHandlers)
1741
+ Handler->beginInstruction (&MI);
1781
1742
1782
1743
if (isVerbose ())
1783
1744
emitComments (MI, OutStreamer->getCommentOS ());
@@ -1871,8 +1832,8 @@ void AsmPrinter::emitFunctionBody() {
1871
1832
if (MCSymbol *S = MI.getPostInstrSymbol ())
1872
1833
OutStreamer->emitLabel (S);
1873
1834
1874
- for (const auto &HI : DebugHandlers)
1875
- HI. Handler ->endInstruction ();
1835
+ for (auto &Handler : DebugHandlers)
1836
+ Handler->endInstruction ();
1876
1837
}
1877
1838
1878
1839
// We must emit temporary symbol for the end of this basic block, if either
@@ -2003,22 +1964,13 @@ void AsmPrinter::emitFunctionBody() {
2003
1964
// Call endBasicBlockSection on the last block now, if it wasn't already
2004
1965
// called.
2005
1966
if (!MF->back ().isEndSection ()) {
2006
- for (const auto &HI : DebugHandlers) {
2007
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2008
- HI.TimerGroupDescription , TimePassesIsEnabled);
2009
- HI.Handler ->endBasicBlockSection (MF->back ());
2010
- }
2011
- for (const auto &HI : Handlers) {
2012
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2013
- HI.TimerGroupDescription , TimePassesIsEnabled);
2014
- HI.Handler ->endBasicBlockSection (MF->back ());
2015
- }
2016
- }
2017
- for (const auto &HI : Handlers) {
2018
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2019
- HI.TimerGroupDescription , TimePassesIsEnabled);
2020
- HI.Handler ->markFunctionEnd ();
1967
+ for (auto &Handler : DebugHandlers)
1968
+ Handler->endBasicBlockSection (MF->back ());
1969
+ for (auto &Handler : Handlers)
1970
+ Handler->endBasicBlockSection (MF->back ());
2021
1971
}
1972
+ for (auto &Handler : Handlers)
1973
+ Handler->markFunctionEnd ();
2022
1974
2023
1975
MBBSectionRanges[MF->front ().getSectionIDNum ()] =
2024
1976
MBBSectionRange{CurrentFnBegin, CurrentFnEnd};
@@ -2027,16 +1979,10 @@ void AsmPrinter::emitFunctionBody() {
2027
1979
emitJumpTableInfo ();
2028
1980
2029
1981
// Emit post-function debug and/or EH information.
2030
- for (const auto &HI : DebugHandlers) {
2031
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2032
- HI.TimerGroupDescription , TimePassesIsEnabled);
2033
- HI.Handler ->endFunction (MF);
2034
- }
2035
- for (const auto &HI : Handlers) {
2036
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2037
- HI.TimerGroupDescription , TimePassesIsEnabled);
2038
- HI.Handler ->endFunction (MF);
2039
- }
1982
+ for (auto &Handler : DebugHandlers)
1983
+ Handler->endFunction (MF);
1984
+ for (auto &Handler : Handlers)
1985
+ Handler->endFunction (MF);
2040
1986
2041
1987
// Emit section containing BB address offsets and their metadata, when
2042
1988
// BB labels are requested for this function. Skip empty functions.
@@ -2473,16 +2419,10 @@ bool AsmPrinter::doFinalization(Module &M) {
2473
2419
emitGlobalIFunc (M, IFunc);
2474
2420
2475
2421
// Finalize debug and EH information.
2476
- for (const auto &HI : DebugHandlers) {
2477
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2478
- HI.TimerGroupDescription , TimePassesIsEnabled);
2479
- HI.Handler ->endModule ();
2480
- }
2481
- for (const auto &HI : Handlers) {
2482
- NamedRegionTimer T (HI.TimerName , HI.TimerDescription , HI.TimerGroupName ,
2483
- HI.TimerGroupDescription , TimePassesIsEnabled);
2484
- HI.Handler ->endModule ();
2485
- }
2422
+ for (auto &Handler : DebugHandlers)
2423
+ Handler->endModule ();
2424
+ for (auto &Handler : Handlers)
2425
+ Handler->endModule ();
2486
2426
2487
2427
// This deletes all the ephemeral handlers that AsmPrinter added, while
2488
2428
// keeping all the user-added handlers alive until the AsmPrinter is
@@ -4004,9 +3944,9 @@ static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB,
4004
3944
void AsmPrinter::emitBasicBlockStart (const MachineBasicBlock &MBB) {
4005
3945
// End the previous funclet and start a new one.
4006
3946
if (MBB.isEHFuncletEntry ()) {
4007
- for (const auto &HI : Handlers) {
4008
- HI. Handler ->endFunclet ();
4009
- HI. Handler ->beginFunclet (MBB);
3947
+ for (auto &Handler : Handlers) {
3948
+ Handler->endFunclet ();
3949
+ Handler->beginFunclet (MBB);
4010
3950
}
4011
3951
}
4012
3952
@@ -4077,21 +4017,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
4077
4017
// if it begins a section (Entry block call is handled separately, next to
4078
4018
// beginFunction).
4079
4019
if (MBB.isBeginSection () && !MBB.isEntryBlock ()) {
4080
- for (const auto &HI : DebugHandlers)
4081
- HI. Handler ->beginBasicBlockSection (MBB);
4082
- for (const auto &HI : Handlers)
4083
- HI. Handler ->beginBasicBlockSection (MBB);
4020
+ for (auto &Handler : DebugHandlers)
4021
+ Handler->beginBasicBlockSection (MBB);
4022
+ for (auto &Handler : Handlers)
4023
+ Handler->beginBasicBlockSection (MBB);
4084
4024
}
4085
4025
}
4086
4026
4087
4027
void AsmPrinter::emitBasicBlockEnd (const MachineBasicBlock &MBB) {
4088
4028
// Check if CFI information needs to be updated for this MBB with basic block
4089
4029
// sections.
4090
4030
if (MBB.isEndSection ()) {
4091
- for (const auto &HI : DebugHandlers)
4092
- HI. Handler ->endBasicBlockSection (MBB);
4093
- for (const auto &HI : Handlers)
4094
- HI. Handler ->endBasicBlockSection (MBB);
4031
+ for (auto &Handler : DebugHandlers)
4032
+ Handler->endBasicBlockSection (MBB);
4033
+ for (auto &Handler : Handlers)
4034
+ Handler->endBasicBlockSection (MBB);
4095
4035
}
4096
4036
}
4097
4037
0 commit comments