@@ -1432,7 +1432,7 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) {
14321432 MCSection *BBAddrMapSection =
14331433 getObjFileLowering ().getBBAddrMapSection (*MF.getSection ());
14341434 assert (BBAddrMapSection && " .llvm_bb_addr_map section is not initialized." );
1435- bool HasCalls = !CurrentFnCallsiteSymbols .empty ();
1435+ bool HasCalls = !CurrentFnCallsiteEndSymbols .empty ();
14361436
14371437 const MCSymbol *FunctionSymbol = getFunctionBegin ();
14381438
@@ -1497,13 +1497,13 @@ void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) {
14971497 emitLabelDifferenceAsULEB128 (MBBSymbol, PrevMBBEndSymbol);
14981498 const MCSymbol *CurrentLabel = MBBSymbol;
14991499 if (HasCalls) {
1500- auto CallsiteSymbols = CurrentFnCallsiteSymbols .lookup (&MBB);
1500+ auto CallsiteEndSymbols = CurrentFnCallsiteEndSymbols .lookup (&MBB);
15011501 OutStreamer->AddComment (" number of callsites" );
1502- OutStreamer->emitULEB128IntValue (CallsiteSymbols .size ());
1503- for (const MCSymbol *CallsiteSymbol : CallsiteSymbols ) {
1502+ OutStreamer->emitULEB128IntValue (CallsiteEndSymbols .size ());
1503+ for (const MCSymbol *CallsiteEndSymbol : CallsiteEndSymbols ) {
15041504 // Emit the callsite offset.
1505- emitLabelDifferenceAsULEB128 (CallsiteSymbol , CurrentLabel);
1506- CurrentLabel = CallsiteSymbol ;
1505+ emitLabelDifferenceAsULEB128 (CallsiteEndSymbol , CurrentLabel);
1506+ CurrentLabel = CallsiteEndSymbol ;
15071507 }
15081508 }
15091509 // Emit the offset to the end of the block, which can be used to compute
@@ -1941,8 +1941,6 @@ void AsmPrinter::emitFunctionBody() {
19411941 !MI.isDebugInstr ()) {
19421942 HasAnyRealCode = true ;
19431943 }
1944- if (MI.isCall () && MF->getTarget ().Options .BBAddrMap )
1945- OutStreamer->emitLabel (createCallsiteSymbol (MBB));
19461944
19471945 // If there is a pre-instruction symbol, emit a label for it here.
19481946 if (MCSymbol *S = MI.getPreInstrSymbol ())
@@ -2064,6 +2062,9 @@ void AsmPrinter::emitFunctionBody() {
20642062 break ;
20652063 }
20662064
2065+ if (MI.isCall () && MF->getTarget ().Options .BBAddrMap )
2066+ OutStreamer->emitLabel (createCallsiteEndSymbol (MBB));
2067+
20672068 if (TM.Options .EmitCallGraphSection && MI.isCall ())
20682069 emitIndirectCalleeLabels (FuncInfo, CallSitesInfoMap, MI);
20692070
@@ -2897,11 +2898,11 @@ MCSymbol *AsmPrinter::getMBBExceptionSym(const MachineBasicBlock &MBB) {
28972898 return Res.first ->second ;
28982899}
28992900
2900- MCSymbol *AsmPrinter::createCallsiteSymbol (const MachineBasicBlock &MBB) {
2901+ MCSymbol *AsmPrinter::createCallsiteEndSymbol (const MachineBasicBlock &MBB) {
29012902 MCContext &Ctx = MF->getContext ();
29022903 MCSymbol *Sym = Ctx.createTempSymbol (" BB" + Twine (MF->getFunctionNumber ()) +
29032904 " _" + Twine (MBB.getNumber ()) + " _CS" );
2904- CurrentFnCallsiteSymbols [&MBB].push_back (Sym);
2905+ CurrentFnCallsiteEndSymbols [&MBB].push_back (Sym);
29052906 return Sym;
29062907}
29072908
@@ -2939,7 +2940,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
29392940 CurrentFnBegin = nullptr ;
29402941 CurrentFnBeginLocal = nullptr ;
29412942 CurrentSectionBeginSym = nullptr ;
2942- CurrentFnCallsiteSymbols .clear ();
2943+ CurrentFnCallsiteEndSymbols .clear ();
29432944 MBBSectionRanges.clear ();
29442945 MBBSectionExceptionSyms.clear ();
29452946 bool NeedsLocalForSize = MAI->needsLocalForSize ();
0 commit comments