@@ -1428,11 +1428,11 @@ getBBAddrMapFeature(const MachineFunction &MF, int NumMBBSectionRanges,
1428
1428
HasCalls};
1429
1429
}
1430
1430
1431
- void AsmPrinter::emitBBAddrMapSection (const MachineFunction &MF,
1432
- bool HasCalls) {
1431
+ void AsmPrinter::emitBBAddrMapSection (const MachineFunction &MF) {
1433
1432
MCSection *BBAddrMapSection =
1434
1433
getObjFileLowering ().getBBAddrMapSection (*MF.getSection ());
1435
1434
assert (BBAddrMapSection && " .llvm_bb_addr_map section is not initialized." );
1435
+ bool HasCalls = !CurrentFnCallsiteSymbols.empty ();
1436
1436
1437
1437
const MCSymbol *FunctionSymbol = getFunctionBegin ();
1438
1438
@@ -1498,7 +1498,7 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF,
1498
1498
const MCSymbol *CurrentLabel = MBBSymbol;
1499
1499
if (HasCalls) {
1500
1500
const SmallVectorImpl<MCSymbol *> &CallsiteSymbols =
1501
- MBB. getCallsiteSymbols ( );
1501
+ CurrentFnCallsiteSymbols. lookup (&MBB );
1502
1502
OutStreamer->AddComment (" number of callsites" );
1503
1503
OutStreamer->emitULEB128IntValue (CallsiteSymbols.size ());
1504
1504
for (const MCSymbol *CallsiteSymbol : CallsiteSymbols) {
@@ -1815,7 +1815,6 @@ void AsmPrinter::emitFunctionBody() {
1815
1815
1816
1816
// Print out code for the function.
1817
1817
bool HasAnyRealCode = false ;
1818
- bool HasCalls = false ;
1819
1818
int NumInstsInFunction = 0 ;
1820
1819
bool IsEHa = MMI->getModule ()->getModuleFlag (" eh-asynch" );
1821
1820
@@ -1842,11 +1841,8 @@ void AsmPrinter::emitFunctionBody() {
1842
1841
!MI.isDebugInstr ()) {
1843
1842
HasAnyRealCode = true ;
1844
1843
}
1845
- if (MI.isCall ()) {
1846
- HasCalls = true ;
1847
- if (MF->getTarget ().Options .BBAddrMap )
1848
- OutStreamer->emitLabel (MBB.createCallsiteSymbol ());
1849
- }
1844
+ if (MI.isCall () && MF->getTarget ().Options .BBAddrMap )
1845
+ OutStreamer->emitLabel (createCallsiteSymbol (MBB));
1850
1846
1851
1847
// If there is a pre-instruction symbol, emit a label for it here.
1852
1848
if (MCSymbol *S = MI.getPreInstrSymbol ())
@@ -2133,7 +2129,7 @@ void AsmPrinter::emitFunctionBody() {
2133
2129
// BB labels are requested for this function. Skip empty functions.
2134
2130
if (HasAnyRealCode) {
2135
2131
if (MF->getTarget ().Options .BBAddrMap )
2136
- emitBBAddrMapSection (*MF, HasCalls );
2132
+ emitBBAddrMapSection (*MF);
2137
2133
else if (PgoAnalysisMapFeatures.getBits () != 0 )
2138
2134
MF->getContext ().reportWarning (
2139
2135
SMLoc (), " pgo-analysis-map is enabled for function " + MF->getName () +
@@ -2794,6 +2790,14 @@ MCSymbol *AsmPrinter::getMBBExceptionSym(const MachineBasicBlock &MBB) {
2794
2790
return Res.first ->second ;
2795
2791
}
2796
2792
2793
+ MCSymbol *AsmPrinter::createCallsiteSymbol (const MachineBasicBlock &MBB) {
2794
+ MCContext &Ctx = MF->getContext ();
2795
+ MCSymbol *Sym = Ctx.createTempSymbol (" BB" + Twine (MF->getFunctionNumber ()) +
2796
+ " _" + Twine (MBB.getNumber ()) + " _CS" );
2797
+ CurrentFnCallsiteSymbols[&MBB].push_back (Sym);
2798
+ return Sym;
2799
+ }
2800
+
2797
2801
void AsmPrinter::SetupMachineFunction (MachineFunction &MF) {
2798
2802
this ->MF = &MF;
2799
2803
const Function &F = MF.getFunction ();
@@ -2828,6 +2832,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
2828
2832
CurrentFnBegin = nullptr ;
2829
2833
CurrentFnBeginLocal = nullptr ;
2830
2834
CurrentSectionBeginSym = nullptr ;
2835
+ CurrentFnCallsiteSymbols.clear ();
2831
2836
MBBSectionRanges.clear ();
2832
2837
MBBSectionExceptionSyms.clear ();
2833
2838
bool NeedsLocalForSize = MAI->needsLocalForSize ();
0 commit comments