@@ -436,6 +436,7 @@ bool AsmPrinter::doInitialization(Module &M) {
436436 MMI = MMIWP ? &MMIWP->getMMI () : nullptr ;
437437 HasSplitStack = false ;
438438 HasNoSplitStack = false ;
439+ DbgInfoAvailable = !M.debug_compile_units ().empty ();
439440
440441 AddrLabelSymbols = nullptr ;
441442
@@ -541,8 +542,7 @@ bool AsmPrinter::doInitialization(Module &M) {
541542 if (EmitCodeView && TM.getTargetTriple ().isOSWindows ())
542543 DebugHandlers.push_back (std::make_unique<CodeViewDebug>(this ));
543544 if (!EmitCodeView || M.getDwarfVersion ()) {
544- assert (MMI && " MMI could not be nullptr here!" );
545- if (MMI->hasDebugInfo ()) {
545+ if (hasDebugInfo ()) {
546546 DD = new DwarfDebug (this );
547547 DebugHandlers.push_back (std::unique_ptr<DwarfDebug>(DD));
548548 }
@@ -1278,7 +1278,7 @@ AsmPrinter::getFunctionCFISectionType(const Function &F) const {
12781278 return CFISection::EH;
12791279
12801280 assert (MMI != nullptr && " Invalid machine module info" );
1281- if (MMI-> hasDebugInfo () || TM.Options .ForceDwarfFrameSection )
1281+ if (hasDebugInfo () || TM.Options .ForceDwarfFrameSection )
12821282 return CFISection::Debug;
12831283
12841284 return CFISection::None;
@@ -1669,11 +1669,10 @@ void AsmPrinter::emitPCSections(const MachineFunction &MF) {
16691669}
16701670
16711671// / Returns true if function begin and end labels should be emitted.
1672- static bool needFuncLabels (const MachineFunction &MF,
1673- const MachineModuleInfo &MMI) {
1672+ static bool needFuncLabels (const MachineFunction &MF, const AsmPrinter &Asm) {
16741673 if (!MF.getLandingPads ().empty () || MF.hasEHFunclets () ||
1675- MMI. hasDebugInfo ( ) ||
1676- MF. getFunction (). hasMetadata (LLVMContext::MD_pcsections ))
1674+ MF. getFunction (). hasMetadata (LLVMContext::MD_pcsections ) ||
1675+ Asm. hasDebugInfo ( ))
16771676 return true ;
16781677
16791678 // We might emit an EH table that uses function begin and end labels even if
@@ -1944,7 +1943,7 @@ void AsmPrinter::emitFunctionBody() {
19441943 // are automatically sized.
19451944 bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective () && !TT.isWasm ();
19461945
1947- if (needFuncLabels (*MF, *MMI) || EmitFunctionSize ) {
1946+ if (EmitFunctionSize || needFuncLabels (*MF, *this ) ) {
19481947 // Create a symbol for the end of function.
19491948 CurrentFnEnd = createTempSymbol (" func_end" );
19501949 OutStreamer->emitLabel (CurrentFnEnd);
@@ -2588,7 +2587,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
25882587 if (F.hasFnAttribute (" patchable-function-entry" ) ||
25892588 F.hasFnAttribute (" function-instrument" ) ||
25902589 F.hasFnAttribute (" xray-instruction-threshold" ) ||
2591- needFuncLabels (MF, *MMI ) || NeedsLocalForSize ||
2590+ needFuncLabels (MF, *this ) || NeedsLocalForSize ||
25922591 MF.getTarget ().Options .EmitStackSizeSection ||
25932592 MF.getTarget ().Options .BBAddrMap || MF.hasBBLabels ()) {
25942593 CurrentFnBegin = createTempSymbol (" func_begin" );
0 commit comments