Use the existing begin and end symbol for debug info.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Mar 2015 02:05:42 +0000 (02:05 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Mar 2015 02:05:42 +0000 (02:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231338 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp
test/DebugInfo/COFF/asan-module-ctor.ll
test/DebugInfo/COFF/asm.ll
test/DebugInfo/COFF/multifile.ll
test/DebugInfo/COFF/multifunction.ll
test/DebugInfo/COFF/simple.ll
test/DebugInfo/COFF/tail-call-without-lexical-scopes.ll
test/DebugInfo/X86/debug-loc-asan.ll
test/DebugInfo/X86/pr19307.ll

index 3721458d6995b759e09e2182112f63d3abf84dc2..0f9edf1d0e9998ee03268132b22425fb79d57502 100644 (file)
@@ -556,7 +556,7 @@ void AsmPrinter::EmitFunctionHeader() {
     OutStreamer.EmitLabel(DeadBlockSyms[i]);
   }
 
-  if (!MMI->getLandingPads().empty()) {
+  if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo()) {
     CurrentFnBegin = createTempSymbol("func_begin", getFunctionNumber());
 
     if (MAI->useAssignmentForEHBegin()) {
@@ -882,7 +882,8 @@ void AsmPrinter::EmitFunctionBody() {
   // Emit target-specific gunk after the function body.
   EmitFunctionBodyEnd();
 
-  if (!MMI->getLandingPads().empty() || MAI->hasDotTypeDotSizeDirective()) {
+  if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
+      MAI->hasDotTypeDotSizeDirective()) {
     // Create a symbol for the end of function.
     CurrentFnEnd = createTempSymbol("func_end", getFunctionNumber());
     OutStreamer.EmitLabel(CurrentFnEnd);
index 5ec83c2480ded57aa2927e25b418cdd8c6e8e121..4d877440bea8d773c1e7d46c148d6e621323a2ab 100644 (file)
@@ -287,7 +287,7 @@ void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
 DIE &DwarfCompileUnit::updateSubprogramScopeDIE(DISubprogram SP) {
   DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
 
-  attachLowHighPC(*SPDie, DD->getFunctionBeginSym(), DD->getFunctionEndSym());
+  attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd());
   if (!DD->getCurrentFunction()->getTarget().Options.DisableFramePointerElim(
           *DD->getCurrentFunction()))
     addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
index 385c1fdf39896dc607641d6046e98ae87996575d..40c7f3b0dec5c0b531727ab1750b8f64c0952098 100644 (file)
@@ -207,7 +207,6 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
   DwarfLineSectionSym = nullptr;
   DwarfAddrSectionSym = nullptr;
   DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = nullptr;
-  FunctionBeginSym = FunctionEndSym = nullptr;
   CurFn = nullptr;
   CurMI = nullptr;
 
@@ -855,7 +854,7 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     if (End != nullptr)
       EndLabel = getLabelAfterInsn(End);
     else if (std::next(I) == Ranges.end())
-      EndLabel = FunctionEndSym;
+      EndLabel = Asm->getFunctionEnd();
     else
       EndLabel = getLabelBeforeInsn(std::next(I)->first);
     assert(EndLabel && "Forgot label after instruction ending a range!");
@@ -1146,11 +1145,6 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
   else
     Asm->OutStreamer.getContext().setDwarfCompileUnitID(TheCU->getUniqueID());
 
-  // Emit a label for the function so that we have a beginning address.
-  FunctionBeginSym = Asm->GetTempSymbol("func_begin", Asm->getFunctionNumber());
-  // Assumes in correct section after the entry point.
-  Asm->OutStreamer.EmitLabel(FunctionBeginSym);
-
   // Calculate history for local variables.
   calculateDbgValueHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(),
                            DbgValues);
@@ -1161,12 +1155,12 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
     if (Ranges.empty())
       continue;
 
-    // The first mention of a function argument gets the FunctionBeginSym
+    // The first mention of a function argument gets the CurrentFnBegin
     // label, so arguments are visible when breaking at function entry.
     DIVariable DIVar(Ranges.front().first->getDebugVariable());
     if (DIVar.isVariable() && DIVar.getTag() == dwarf::DW_TAG_arg_variable &&
         getDISubprogram(DIVar.getContext()).describes(MF->getFunction())) {
-      LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym;
+      LabelsBeforeInsn[Ranges.front().first] = Asm->getFunctionBegin();
       if (Ranges.front().first->getDebugExpression().isBitPiece()) {
         // Mark all non-overlapping initial pieces.
         for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
@@ -1175,7 +1169,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
                           [&](DbgValueHistoryMap::InstrRange Pred) {
                 return !piecesOverlap(Piece, Pred.first->getDebugExpression());
               }))
-            LabelsBeforeInsn[I->first] = FunctionBeginSym;
+            LabelsBeforeInsn[I->first] = Asm->getFunctionBegin();
           else
             break;
         }
@@ -1190,7 +1184,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
   }
 
   PrevInstLoc = DebugLoc();
-  PrevLabel = FunctionBeginSym;
+  PrevLabel = Asm->getFunctionBegin();
 
   // Record beginning of function.
   PrologEndLoc = findPrologueEndLoc(MF);
@@ -1221,11 +1215,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
     return;
   }
 
-  // Define end label for subprogram.
-  FunctionEndSym = Asm->GetTempSymbol("func_end", Asm->getFunctionNumber());
-  // Assumes in correct section after the entry point.
-  Asm->OutStreamer.EmitLabel(FunctionEndSym);
-
   // Set DwarfDwarfCompileUnitID in MCContext to default value.
   Asm->OutStreamer.getContext().setDwarfCompileUnitID(0);
 
@@ -1237,7 +1226,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
   collectVariableInfo(TheCU, SP, ProcessedVars);
 
   // Add the range of this function to the list of ranges for the CU.
-  TheCU.addRange(RangeSpan(FunctionBeginSym, FunctionEndSym));
+  TheCU.addRange(RangeSpan(Asm->getFunctionBegin(), Asm->getFunctionEnd()));
 
   // Under -gmlt, skip building the subprogram if there are no inlined
   // subroutines inside it.
index d1137297b3bcbaea2985210808c6547671f9ee3e..a15f200569334ffc0a24f66cccb735b0a2a1a544 100644 (file)
@@ -249,7 +249,6 @@ class DwarfDebug : public AsmPrinterHandler {
   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
-  MCSymbol *FunctionBeginSym, *FunctionEndSym;
   MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
   MCSymbol *DwarfTypesDWOSectionSym;
   MCSymbol *DwarfStrDWOSectionSym;
@@ -627,8 +626,6 @@ public:
   void addAccelType(StringRef Name, const DIE &Die, char Flags);
 
   const MachineFunction *getCurrentFunction() const { return CurFn; }
-  const MCSymbol *getFunctionBeginSym() const { return FunctionBeginSym; }
-  const MCSymbol *getFunctionEndSym() const { return FunctionEndSym; }
 
   iterator_range<ImportedEntityMap::const_iterator>
   findImportedEntitiesForScope(const MDNode *Scope) const {
index b5e0929efd91a5e8bd396f3328adca11c5f797b5..96a503679027b93d82caa8f398c2df4501feea94 100644 (file)
@@ -364,10 +364,7 @@ void WinCodeViewLineTables::endFunction(const MachineFunction *MF) {
     FnDebugInfo.erase(GV);
     VisitedFunctions.pop_back();
   } else {
-    // Define end label for subprogram.
-    MCSymbol *FunctionEndSym = Asm->OutStreamer.getContext().CreateTempSymbol();
-    Asm->OutStreamer.EmitLabel(FunctionEndSym);
-    CurFn->End = FunctionEndSym;
+    CurFn->End = Asm->getFunctionEnd();
   }
   CurFn = nullptr;
 }
index 620512945146c54b9fc8b9e994e7a1613be20bcc..ee693d6ae8579282e8f3a3ba31ab429772480447 100644 (file)
@@ -9,6 +9,7 @@
 
 ; The module ctor has no debug info.  All we have to do is don't crash.
 ; X86: _asan.module_ctor:
+; X86-NEXT: L{{.*}}:
 ; X86-NEXT: # BB
 ; X86-NEXT: calll   ___asan_init_v3
 ; X86-NEXT: retl
index 1a3621a29b9ac03835480ed681a695dd59ef0dd1..cccf43f178dabd3960518a772d0d63d4192b0af3 100644 (file)
 ; OBJ32:    }
 
 ; X64-LABEL: f:
+; X64-NEXT: .L{{.*}}:{{$}}
 ; X64-NEXT: [[START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
index 2dc51035c021f473acca717a13f0010d00c8ac88..91e2d9cd036fa5601a0ef4618db0140a913e79cc 100644 (file)
 ; OBJ32:    }
 
 ; X64-LABEL: f:
+; X64-NEXT: .L{{.*}}:{{$}}
 ; X64-NEXT: [[START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
index 8f78a8f50b40edf3fb771709a2c85893d8665152..48a927f3b01bd61e4de9fef8c53cc953e04b7f2b 100644 (file)
 ; OBJ32:    }
 
 ; X64-LABEL: x:
+; X64-NEXT: .L{{.*}}:
 ; X64-NEXT: [[X_START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
 ; X64-NEXT: [[END_OF_X:.*]]:
 ;
 ; X64-LABEL: y:
+; X64-NEXT: .L{{.*}}:
 ; X64-NEXT: [[Y_START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
 ; X64-NEXT: [[END_OF_Y:.*]]:
 ;
 ; X64-LABEL: f:
+; X64-NEXT: .L{{.*}}:
 ; X64-NEXT: [[F_START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
index d785de09edda5f0a95408e09f4b72baba2ec3aa7..2f713a984b4ef27eb2bb920598468af0e17610f5 100644 (file)
 ; OBJ32:    }
 
 ; X64-LABEL: f:
+; X64-NEXT: .L{{.*}}:{{$}}
 ; X64-NEXT: [[START:.*]]:{{$}}
 ; X64:      # BB
 ; X64:      subq    $40, %rsp
index 28e874905fe67b97fdc243375521e43166d829a8..4fb8a5be885f407940d267e857758422029ccbb1 100644 (file)
@@ -16,6 +16,7 @@
 ; with debug information available.  This used to be PR19239.
 
 ; X86-LABEL: {{^}}"?bar@@YAXHZZ":
+; X86-NEXT: L{{.*}}:
 ; X86-NEXT: # BB
 ; X86-NEXT: [[JMP_LINE:^L.*]]:{{$}}
 ; X86:      jmp "?foo@@YAXXZ"
index 4a087f342f3d38b566651a6951d6d09c3b5ce69f..b15668a7547c592d114b97010b024e7b4ce7e480 100644 (file)
@@ -28,7 +28,7 @@
 
 ; Then it's addressed via %rsp:
 ; CHECK:      .quad [[START_LABEL]]-.Lfunc_begin0
-; CHECK-NEXT: .Lfunc_end06-.Lfunc_begin0
+; CHECK-NEXT: .Lfunc_end0-.Lfunc_begin0
 ; CHECK: DW_OP_breg7
 ; CHECK-NEXT: [[OFFSET]]
 ; CHECK: DW_OP_deref
index 13023ac8b8f68d4fdb34bed672bb0b7cee557741..e673f1d7cf3e7922d72a118761ff30e8a0754f78 100644 (file)
@@ -21,7 +21,7 @@
 ; CHECK: .Ldebug_loc{{[0-9]+}}:
 ; CHECK: DW_OP_breg1
 ; CHECK:      .quad [[START_LABEL]]-.Lfunc_begin0
-; CHECK-NEXT: .quad .Lfunc_end09-.Lfunc_begin0
+; CHECK-NEXT: .quad .Lfunc_end0-.Lfunc_begin0
 ; CHECK: DW_OP_breg6
 ; CHECK: DW_OP_deref