[llvm] r340883 - [codeview] Clean up machinery for deferring .cv_loc emission

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 16:25:59 PDT 2018


Author: rnk
Date: Tue Aug 28 16:25:59 2018
New Revision: 340883

URL: http://llvm.org/viewvc/llvm-project?rev=340883&view=rev
Log:
[codeview] Clean up machinery for deferring .cv_loc emission

Now that we create the label at the point of the directive, we don't
need to set the "current CV location", and then later when we emit the
next instruction, create a label for it and emit it.

DWARF still defers the labels used in .debug_loc until the next
instruction or value, for reasons unknown.

Modified:
    llvm/trunk/include/llvm/MC/MCCodeView.h
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/MC/MCCodeView.cpp
    llvm/trunk/lib/MC/MCContext.cpp
    llvm/trunk/lib/MC/MCObjectStreamer.cpp
    llvm/trunk/lib/MC/MCStreamer.cpp
    llvm/trunk/test/DebugInfo/COFF/asm.ll
    llvm/trunk/test/DebugInfo/COFF/inlining-header.ll
    llvm/trunk/test/DebugInfo/COFF/inlining.ll
    llvm/trunk/test/DebugInfo/COFF/local-variables.ll
    llvm/trunk/test/DebugInfo/COFF/multifile.ll
    llvm/trunk/test/DebugInfo/COFF/multifunction.ll
    llvm/trunk/test/DebugInfo/COFF/simple.ll

Modified: llvm/trunk/include/llvm/MC/MCCodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCCodeView.h?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCCodeView.h (original)
+++ llvm/trunk/include/llvm/MC/MCCodeView.h Tue Aug 28 16:25:59 2018
@@ -30,6 +30,7 @@ class CodeViewContext;
 /// Instances of this class represent the information from a
 /// .cv_loc directive.
 class MCCVLoc {
+  const MCSymbol *Label = nullptr;
   uint32_t FunctionId;
   uint32_t FileNum;
   uint32_t Line;
@@ -39,15 +40,17 @@ class MCCVLoc {
 
 private: // CodeViewContext manages these
   friend class CodeViewContext;
-  MCCVLoc(unsigned functionid, unsigned fileNum, unsigned line, unsigned column,
-          bool prologueend, bool isstmt)
-      : FunctionId(functionid), FileNum(fileNum), Line(line), Column(column),
-        PrologueEnd(prologueend), IsStmt(isstmt) {}
+  MCCVLoc(const MCSymbol *Label, unsigned functionid, unsigned fileNum,
+          unsigned line, unsigned column, bool prologueend, bool isstmt)
+      : Label(Label), FunctionId(functionid), FileNum(fileNum), Line(line),
+        Column(column), PrologueEnd(prologueend), IsStmt(isstmt) {}
 
   // Allow the default copy constructor and assignment operator to be used
   // for an MCCVLoc object.
 
 public:
+  const MCSymbol *getLabel() const { return Label; }
+
   unsigned getFunctionId() const { return FunctionId; }
 
   /// Get the FileNum of this MCCVLoc.
@@ -62,6 +65,8 @@ public:
   bool isPrologueEnd() const { return PrologueEnd; }
   bool isStmt() const { return IsStmt; }
 
+  void setLabel(const MCSymbol *L) { Label = L; }
+
   void setFunctionId(unsigned FID) { FunctionId = FID; }
 
   /// Set the FileNum of this MCCVLoc.
@@ -80,31 +85,6 @@ public:
   void setIsStmt(bool IS) { IsStmt = IS; }
 };
 
-/// Instances of this class represent the line information for
-/// the CodeView line table entries.  Which is created after a machine
-/// instruction is assembled and uses an address from a temporary label
-/// created at the current address in the current section and the info from
-/// the last .cv_loc directive seen as stored in the context.
-class MCCVLineEntry : public MCCVLoc {
-  const MCSymbol *Label;
-
-private:
-  // Allow the default copy constructor and assignment operator to be used
-  // for an MCCVLineEntry object.
-
-public:
-  // Constructor to create an MCCVLineEntry given a symbol and the dwarf loc.
-  MCCVLineEntry(const MCSymbol *Label, const MCCVLoc loc)
-      : MCCVLoc(loc), Label(Label) {}
-
-  const MCSymbol *getLabel() const { return Label; }
-
-  // This is called when an instruction is assembled into the specified
-  // section and if there is information from the last .cv_loc directive that
-  // has yet to have a line entry made for it is made.
-  static void Make(MCObjectStreamer *MCOS);
-};
-
 /// Information describing a function or inlined call site introduced by
 /// .cv_func_id or .cv_inline_site_id. Accumulates information from .cv_loc
 /// directives used with this function's id or the id of an inlined call site
@@ -183,32 +163,20 @@ public:
   /// and sets CVLocSeen.  When the next instruction is assembled an entry
   /// in the line number table with this information and the address of the
   /// instruction will be created.
-  void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line,
-                       unsigned Column, bool PrologueEnd, bool IsStmt) {
-    CurrentCVLoc.setFunctionId(FunctionId);
-    CurrentCVLoc.setFileNum(FileNo);
-    CurrentCVLoc.setLine(Line);
-    CurrentCVLoc.setColumn(Column);
-    CurrentCVLoc.setPrologueEnd(PrologueEnd);
-    CurrentCVLoc.setIsStmt(IsStmt);
-    CVLocSeen = true;
-  }
-
-  bool getCVLocSeen() { return CVLocSeen; }
-  void clearCVLocSeen() { CVLocSeen = false; }
-
-  const MCCVLoc &getCurrentCVLoc() { return CurrentCVLoc; }
+  void recordCVLoc(MCContext &Ctx, const MCSymbol *Label, unsigned FunctionId,
+                   unsigned FileNo, unsigned Line, unsigned Column,
+                   bool PrologueEnd, bool IsStmt);
 
   bool isValidCVFileNumber(unsigned FileNumber);
 
   /// Add a line entry.
-  void addLineEntry(const MCCVLineEntry &LineEntry);
+  void addLineEntry(const MCCVLoc &LineEntry);
 
-  std::vector<MCCVLineEntry> getFunctionLineEntries(unsigned FuncId);
+  std::vector<MCCVLoc> getFunctionLineEntries(unsigned FuncId);
 
   std::pair<size_t, size_t> getLineExtent(unsigned FuncId);
 
-  ArrayRef<MCCVLineEntry> getLinesForExtent(size_t L, size_t R);
+  ArrayRef<MCCVLoc> getLinesForExtent(size_t L, size_t R);
 
   /// Emits a line table substream.
   void emitLineTableForFunction(MCObjectStreamer &OS, unsigned FuncId,
@@ -247,10 +215,6 @@ public:
   std::pair<StringRef, unsigned> addToStringTable(StringRef S);
 
 private:
-  /// The current CodeView line information from the last .cv_loc directive.
-  MCCVLoc CurrentCVLoc = MCCVLoc(0, 0, 0, 0, false, true);
-  bool CVLocSeen = false;
-
   /// Map from string to string table offset.
   StringMap<unsigned> StringTable;
 
@@ -286,8 +250,8 @@ private:
   /// id.
   std::map<unsigned, std::pair<size_t, size_t>> MCCVLineStartStop;
 
-  /// A collection of MCCVLineEntry for each section.
-  std::vector<MCCVLineEntry> MCCVLines;
+  /// A collection of MCCVLoc for each section.
+  std::vector<MCCVLoc> MCCVLines;
 
   /// All known functions and inlined call sites, indexed by function id.
   std::vector<MCCVFunctionInfo> Functions;

Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Tue Aug 28 16:25:59 2018
@@ -298,10 +298,6 @@ namespace llvm {
 
     CodeViewContext &getCVContext();
 
-    /// Clear the current cv_loc, if there is one. Avoids lazily creating a
-    /// CodeViewContext if none is needed.
-    void clearCVLocSeen();
-
     void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
     void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
 

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Aug 28 16:25:59 2018
@@ -231,6 +231,9 @@ protected:
 
   virtual void EmitRawTextImpl(StringRef String);
 
+  /// Returns true if the the .cv_loc directive is in the right section.
+  bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc);
+
 public:
   MCStreamer(const MCStreamer &) = delete;
   MCStreamer &operator=(const MCStreamer &) = delete;

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue Aug 28 16:25:59 2018
@@ -1298,20 +1298,17 @@ void MCAsmStreamer::EmitCVLocDirective(u
                                        unsigned Line, unsigned Column,
                                        bool PrologueEnd, bool IsStmt,
                                        StringRef FileName, SMLoc Loc) {
+  // Validate the directive.
+  if (!checkCVLocSection(FunctionId, FileNo, Loc))
+    return;
+
   OS << "\t.cv_loc\t" << FunctionId << " " << FileNo << " " << Line << " "
      << Column;
   if (PrologueEnd)
     OS << " prologue_end";
 
-  unsigned OldIsStmt = getContext().getCVContext().getCurrentCVLoc().isStmt();
-  if (IsStmt != OldIsStmt) {
-    OS << " is_stmt ";
-
-    if (IsStmt)
-      OS << "1";
-    else
-      OS << "0";
-  }
+  if (IsStmt)
+    OS << " is_stmt 1";
 
   if (IsVerboseAsm) {
     OS.PadToColumn(MAI->getCommentColumn());
@@ -1319,8 +1316,6 @@ void MCAsmStreamer::EmitCVLocDirective(u
        << Column;
   }
   EmitEOL();
-  this->MCStreamer::EmitCVLocDirective(FunctionId, FileNo, Line, Column,
-                                       PrologueEnd, IsStmt, FileName, Loc);
 }
 
 void MCAsmStreamer::EmitCVLinetableDirective(unsigned FunctionId,

Modified: llvm/trunk/lib/MC/MCCodeView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCCodeView.cpp (original)
+++ llvm/trunk/lib/MC/MCCodeView.cpp Tue Aug 28 16:25:59 2018
@@ -128,6 +128,14 @@ bool CodeViewContext::recordInlinedCallS
   return true;
 }
 
+void CodeViewContext::recordCVLoc(MCContext &Ctx, const MCSymbol *Label,
+                                  unsigned FunctionId, unsigned FileNo,
+                                  unsigned Line, unsigned Column,
+                                  bool PrologueEnd, bool IsStmt) {
+  addLineEntry(MCCVLoc{
+      Label, FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt});
+}
+
 MCDataFragment *CodeViewContext::getStringTableFragment() {
   if (!StrTabFragment) {
     StrTabFragment = new MCDataFragment();
@@ -255,7 +263,7 @@ void CodeViewContext::emitFileChecksumOf
   OS.EmitValueImpl(SRE, 4);
 }
 
-void CodeViewContext::addLineEntry(const MCCVLineEntry &LineEntry) {
+void CodeViewContext::addLineEntry(const MCCVLoc &LineEntry) {
   size_t Offset = MCCVLines.size();
   auto I = MCCVLineStartStop.insert(
       {LineEntry.getFunctionId(), {Offset, Offset + 1}});
@@ -264,9 +272,9 @@ void CodeViewContext::addLineEntry(const
   MCCVLines.push_back(LineEntry);
 }
 
-std::vector<MCCVLineEntry>
+std::vector<MCCVLoc>
 CodeViewContext::getFunctionLineEntries(unsigned FuncId) {
-  std::vector<MCCVLineEntry> FilteredLines;
+  std::vector<MCCVLoc> FilteredLines;
   auto I = MCCVLineStartStop.find(FuncId);
   if (I != MCCVLineStartStop.end()) {
     MCCVFunctionInfo *SiteInfo = getCVFunctionInfo(FuncId);
@@ -289,9 +297,9 @@ CodeViewContext::getFunctionLineEntries(
               FilteredLines.back().getFileNum() != IA.File ||
               FilteredLines.back().getLine() != IA.Line ||
               FilteredLines.back().getColumn() != IA.Col) {
-            FilteredLines.push_back(MCCVLineEntry(
+            FilteredLines.push_back(MCCVLoc(
                 MCCVLines[Idx].getLabel(),
-                MCCVLoc(FuncId, IA.File, IA.Line, IA.Col, false, false)));
+                FuncId, IA.File, IA.Line, IA.Col, false, false));
           }
         }
       }
@@ -308,7 +316,7 @@ std::pair<size_t, size_t> CodeViewContex
   return I->second;
 }
 
-ArrayRef<MCCVLineEntry> CodeViewContext::getLinesForExtent(size_t L, size_t R) {
+ArrayRef<MCCVLoc> CodeViewContext::getLinesForExtent(size_t L, size_t R) {
   if (R <= L)
     return None;
   if (L >= MCCVLines.size())
@@ -331,8 +339,8 @@ void CodeViewContext::emitLineTableForFu
   OS.EmitCOFFSectionIndex(FuncBegin);
 
   // Actual line info.
-  std::vector<MCCVLineEntry> Locs = getFunctionLineEntries(FuncId);
-  bool HaveColumns = any_of(Locs, [](const MCCVLineEntry &LineEntry) {
+  std::vector<MCCVLoc> Locs = getFunctionLineEntries(FuncId);
+  bool HaveColumns = any_of(Locs, [](const MCCVLoc &LineEntry) {
     return LineEntry.getColumn() != 0;
   });
   OS.EmitIntValue(HaveColumns ? int(LF_HaveColumns) : 0, 2);
@@ -342,7 +350,7 @@ void CodeViewContext::emitLineTableForFu
     // Emit a file segment for the run of locations that share a file id.
     unsigned CurFileNum = I->getFileNum();
     auto FileSegEnd =
-        std::find_if(I, E, [CurFileNum](const MCCVLineEntry &Loc) {
+        std::find_if(I, E, [CurFileNum](const MCCVLoc &Loc) {
           return Loc.getFileNum() != CurFileNum;
         });
     unsigned EntryCount = FileSegEnd - I;
@@ -468,14 +476,14 @@ void CodeViewContext::encodeInlineLineTa
 
   if (LocBegin >= LocEnd)
     return;
-  ArrayRef<MCCVLineEntry> Locs = getLinesForExtent(LocBegin, LocEnd);
+  ArrayRef<MCCVLoc> Locs = getLinesForExtent(LocBegin, LocEnd);
   if (Locs.empty())
     return;
 
   // Check that the locations are all in the same section.
 #ifndef NDEBUG
   const MCSection *FirstSec = &Locs.front().getLabel()->getSection();
-  for (const MCCVLineEntry &Loc : Locs) {
+  for (const MCCVLoc &Loc : Locs) {
     if (&Loc.getLabel()->getSection() != FirstSec) {
       errs() << ".cv_loc " << Loc.getFunctionId() << ' ' << Loc.getFileNum()
              << ' ' << Loc.getLine() << ' ' << Loc.getColumn()
@@ -488,7 +496,8 @@ void CodeViewContext::encodeInlineLineTa
   // Make an artificial start location using the function start and the inlinee
   // lines start location information. All deltas start relative to this
   // location.
-  MCCVLineEntry StartLoc(Frag.getFnStartSym(), MCCVLoc(Locs.front()));
+  MCCVLoc StartLoc = Locs.front();
+  StartLoc.setLabel(Frag.getFnStartSym());
   StartLoc.setFileNum(Frag.StartFileId);
   StartLoc.setLine(Frag.StartLineNum);
   bool HaveOpenRange = false;
@@ -500,7 +509,7 @@ void CodeViewContext::encodeInlineLineTa
 
   SmallVectorImpl<char> &Buffer = Frag.getContents();
   Buffer.clear(); // Clear old contents if we went through relaxation.
-  for (const MCCVLineEntry &Loc : Locs) {
+  for (const MCCVLoc &Loc : Locs) {
     // Exit early if our line table would produce an oversized InlineSiteSym
     // record. Account for the ChangeCodeLength annotation emitted after the
     // loop ends.
@@ -585,10 +594,10 @@ void CodeViewContext::encodeInlineLineTa
   unsigned EndSymLength =
       computeLabelDiff(Layout, LastLabel, Frag.getFnEndSym());
   unsigned LocAfterLength = ~0U;
-  ArrayRef<MCCVLineEntry> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
+  ArrayRef<MCCVLoc> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
   if (!LocAfter.empty()) {
     // Only try to compute this difference if we're in the same section.
-    const MCCVLineEntry &Loc = LocAfter[0];
+    const MCCVLoc &Loc = LocAfter[0];
     if (&Loc.getLabel()->getSection() == &LastLabel->getSection())
       LocAfterLength = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
   }
@@ -686,31 +695,3 @@ void CodeViewContext::encodeDefRange(MCA
     }
   }
 }
-
-//
-// This is called when an instruction is assembled into the specified section
-// and if there is information from the last .cv_loc directive that has yet to have
-// a line entry made for it is made.
-//
-void MCCVLineEntry::Make(MCObjectStreamer *MCOS) {
-  CodeViewContext &CVC = MCOS->getContext().getCVContext();
-  if (!CVC.getCVLocSeen())
-    return;
-
-  // Create a symbol at in the current section for use in the line entry.
-  MCSymbol *LineSym = MCOS->getContext().createTempSymbol();
-  // Set the value of the symbol to use for the MCCVLineEntry.
-  MCOS->EmitLabel(LineSym);
-
-  // Get the current .loc info saved in the context.
-  const MCCVLoc &CVLoc = CVC.getCurrentCVLoc();
-
-  // Create a (local) line entry with the symbol and the current .loc info.
-  MCCVLineEntry LineEntry(LineSym, CVLoc);
-
-  // clear CVLocSeen saying the current .loc info is now used.
-  CVC.clearCVLocSeen();
-
-  // Add the line entry to this section's entries.
-  CVC.addLineEntry(LineEntry);
-}

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Tue Aug 28 16:25:59 2018
@@ -605,11 +605,6 @@ CodeViewContext &MCContext::getCVContext
   return *CVContext.get();
 }
 
-void MCContext::clearCVLocSeen() {
-  if (CVContext)
-    CVContext->clearCVLocSeen();
-}
-
 //===----------------------------------------------------------------------===//
 // Error Reporting
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue Aug 28 16:25:59 2018
@@ -173,7 +173,6 @@ void MCObjectStreamer::EmitValueImpl(con
   MCDataFragment *DF = getOrCreateDataFragment();
   flushPendingLabels(DF, DF->getContents().size());
 
-  MCCVLineEntry::Make(this);
   MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
 
   // Avoid fixups when possible.
@@ -270,7 +269,6 @@ bool MCObjectStreamer::changeSectionImpl
                                          const MCExpr *Subsection) {
   assert(Section && "Cannot switch to a null section!");
   flushPendingLabels(nullptr);
-  getContext().clearCVLocSeen();
   getContext().clearDwarfLocSeen();
 
   bool Created = getAssembler().registerSection(*Section);
@@ -311,7 +309,6 @@ void MCObjectStreamer::EmitInstructionIm
 
   // Now that a machine instruction has been assembled into this section, make
   // a line entry for any .loc directive that has been seen.
-  MCCVLineEntry::Make(this);
   MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
 
   // If this instruction doesn't need relaxation, just emit it as data.
@@ -446,12 +443,16 @@ void MCObjectStreamer::EmitCVLocDirectiv
                                           unsigned Line, unsigned Column,
                                           bool PrologueEnd, bool IsStmt,
                                           StringRef FileName, SMLoc Loc) {
-  // Unlike dwarf locations, we don't save the MCCVLineEntry until the next
-  // instruction. We create the label exactly where the directive appears in the
-  // assembly.
-  this->MCStreamer::EmitCVLocDirective(FunctionId, FileNo, Line, Column,
-                                       PrologueEnd, IsStmt, FileName, Loc);
-  MCCVLineEntry::Make(this);
+  // Validate the directive.
+  if (!checkCVLocSection(FunctionId, FileNo, Loc))
+    return;
+
+  // Emit a label at the current position and record it in the CodeViewContext.
+  MCSymbol *LineSym = getContext().createTempSymbol();
+  EmitLabel(LineSym);
+  getContext().getCVContext().recordCVLoc(getContext(), LineSym, FunctionId,
+                                          FileNo, Line, Column, PrologueEnd,
+                                          IsStmt);
 }
 
 void MCObjectStreamer::EmitCVLinetableDirective(unsigned FunctionId,
@@ -491,7 +492,6 @@ void MCObjectStreamer::EmitCVFileChecksu
 }
 
 void MCObjectStreamer::EmitBytes(StringRef Data) {
-  MCCVLineEntry::Make(this);
   MCDwarfLineEntry::Make(this, getCurrentSectionOnly());
   MCDataFragment *DF = getOrCreateDataFragment();
   flushPendingLabels(DF, DF->getContents().size());

Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Tue Aug 28 16:25:59 2018
@@ -270,22 +270,28 @@ bool MCStreamer::EmitCVInlineSiteIdDirec
 void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
                                     unsigned Line, unsigned Column,
                                     bool PrologueEnd, bool IsStmt,
-                                    StringRef FileName, SMLoc Loc) {
+                                    StringRef FileName, SMLoc Loc) {}
+
+bool MCStreamer::checkCVLocSection(unsigned FunctionId, unsigned FileNo,
+                                   SMLoc Loc) {
   CodeViewContext &CVC = getContext().getCVContext();
   MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FunctionId);
-  if (!FI)
-    return getContext().reportError(
+  if (!FI) {
+    getContext().reportError(
         Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
+    return false;
+  }
 
   // Track the section
   if (FI->Section == nullptr)
     FI->Section = getCurrentSectionOnly();
-  else if (FI->Section != getCurrentSectionOnly())
-    return getContext().reportError(
+  else if (FI->Section != getCurrentSectionOnly()) {
+    getContext().reportError(
         Loc,
         "all .cv_loc directives for a function must be in the same section");
-
-  CVC.setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt);
+    return false;
+  }
+  return true;
 }
 
 void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,

Modified: llvm/trunk/test/DebugInfo/COFF/asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/asm.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/asm.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/asm.ll Tue Aug 28 16:25:59 2018
@@ -14,7 +14,7 @@
 
 ; X86-LABEL: _f:
 ; X86:      .cv_file 1 "D:\\asm.c"
-; X86:      .cv_loc 0 1 4 0 is_stmt 0
+; X86:      .cv_loc 0 1 4 0
 ; X86:      .cv_loc 0 1 5 0
 ; X86:      calll   _g
 ; X86:      .cv_loc 0 1 6 0
@@ -71,7 +71,7 @@
 
 ; X64-LABEL: f:
 ; X64:      .cv_file 1 "D:\\asm.c"
-; X64:      .cv_loc 0 1 3 0 is_stmt 0
+; X64:      .cv_loc 0 1 3 0
 ; X64:      subq    $40, %rsp
 ; X64:      .cv_loc 0 1 4 0
 ; X64:      .cv_loc 0 1 5 0

Modified: llvm/trunk/test/DebugInfo/COFF/inlining-header.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/inlining-header.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/inlining-header.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/inlining-header.ll Tue Aug 28 16:25:59 2018
@@ -28,7 +28,7 @@
 ; ASM:         .cv_func_id 0
 ; ASM: # %bb.0:                                 # %entry
 ; ASM:         .cv_file        1 "D:\\src\\llvm\\build\\t.cpp"
-; ASM:         .cv_loc 0 1 9 5 is_stmt 0       # t.cpp:9:5
+; ASM:         .cv_loc 0 1 9 5       # t.cpp:9:5
 ; ASM:         incl    "?x@@3HC"
 ; ASM:         .cv_inline_site_id 1 within 0 inlined_at 1 10 3
 ; ASM:         .cv_loc 1 1 4 5                 # t.cpp:4:5

Modified: llvm/trunk/test/DebugInfo/COFF/inlining.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/inlining.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/inlining.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/inlining.ll Tue Aug 28 16:25:59 2018
@@ -22,7 +22,7 @@
 ; 17: }
 
 ; ASM: .cv_func_id 0
-; ASM: .cv_loc 0 1 13 0 is_stmt 0      # t.cpp:13:0
+; ASM: .cv_loc 0 1 13 0      # t.cpp:13:0
 ; ASM: .cv_loc 0 1 14 5                # t.cpp:14:5
 ; ASM: addl    $6, "?x@@3HC"
 ; ASM: .cv_inline_site_id 1 within 0 inlined_at 1 15 3

Modified: llvm/trunk/test/DebugInfo/COFF/local-variables.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/local-variables.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/local-variables.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/local-variables.ll Tue Aug 28 16:25:59 2018
@@ -24,7 +24,7 @@
 ; ASM: f:                                      # @f
 ; ASM:         .cv_func_id 0
 ; ASM:         .cv_file        1 "D:\\src\\llvm\\build\\t.cpp"
-; ASM:         .cv_loc 0 1 7 0 is_stmt 0       # t.cpp:7:0
+; ASM:         .cv_loc 0 1 7 0       # t.cpp:7:0
 ; ASM: .seh_proc f
 ; ASM: # %bb.0:                                 # %entry
 ; ASM:         subq    $56, %rsp

Modified: llvm/trunk/test/DebugInfo/COFF/multifile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/multifile.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/multifile.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/multifile.ll Tue Aug 28 16:25:59 2018
@@ -19,7 +19,7 @@
 ; X86-LABEL: _f:
 ; X86:      # %bb.
 ; X86:      .cv_file 1 "D:\\one.c" "70B51F534D80639D033AE92C6A856AF6" 1
-; X86:      .cv_loc 0 1 1 0 is_stmt 0 # one.c:1:0
+; X86:      .cv_loc 0 1 1 0 # one.c:1:0
 ; X86:      calll   _g
 ; X86:      .cv_file 2 "D:\\two.c" "70B51F534D80639D033AE92C6A856AF6" 1
 ; X86:      .cv_loc 0 2 2 0 # two.c:2:0
@@ -105,7 +105,7 @@
 ; X64-LABEL: f:
 ; X64-NEXT: .L{{.*}}:{{$}}
 ; X64:      .cv_file 1 "D:\\input.c" "70B51F534D80639D033AE92C6A856AF6" 1
-; X64:      .cv_loc 0 1 3 0 is_stmt 0 # input.c:3:0
+; X64:      .cv_loc 0 1 3 0 # input.c:3:0
 ; X64:      # %bb.
 ; X64:      subq    $40, %rsp
 ; X64:      .cv_file 2 "D:\\one.c" "70B51F534D80639D033AE92C6A856AF6" 1

Modified: llvm/trunk/test/DebugInfo/COFF/multifunction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/multifunction.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/multifunction.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/multifunction.ll Tue Aug 28 16:25:59 2018
@@ -25,7 +25,7 @@
 ; X86-LABEL: _x:
 ; X86:      # %bb.
 ; X86:      .cv_file 1 "D:\\source.c"
-; X86:      .cv_loc 0 1 4 42 is_stmt 0 # source.c:4:42
+; X86:      .cv_loc 0 1 4 42 # source.c:4:42
 ; X86:      calll   _z
 ; X86:      .cv_loc 0 1 5 43 # source.c:5:43
 ; X86:      ret
@@ -286,7 +286,7 @@
 ; X64-LABEL: x:
 ; X64-NEXT: .L{{.*}}:
 ; X64:      .cv_file 1 "D:\\source.c"
-; X64:      .cv_loc 0 1 3 0 is_stmt 0 # source.c:3:0
+; X64:      .cv_loc 0 1 3 0 # source.c:3:0
 ; X64:      # %bb.
 ; X64:      subq    $40, %rsp
 ; X64:      .cv_loc 0 1 4 42 # source.c:4:42

Modified: llvm/trunk/test/DebugInfo/COFF/simple.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/simple.ll?rev=340883&r1=340882&r2=340883&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/simple.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/simple.ll Tue Aug 28 16:25:59 2018
@@ -22,7 +22,7 @@
 ; X86-LABEL: _f:
 ; X86:      # %bb.
 ; X86:      .cv_file 1 "D:\\test.c" "F310AB26998CA831CBDF169E4EECACFA" 1
-; X86:      .cv_loc 0 1 4 2 is_stmt 0 # test.c:4:2
+; X86:      .cv_loc 0 1 4 2 # test.c:4:2
 ; X86:      calll   _g
 ; X86:      .cv_loc 0 1 5 0 # test.c:5:0
 ; X86:      ret
@@ -134,7 +134,7 @@
 ; X64-LABEL: f:
 ; X64-NEXT: .L{{.*}}:{{$}}
 ; X64:      .cv_file 1 "D:\\test.c" "F310AB26998CA831CBDF169E4EECACFA" 1
-; X64:      .cv_loc 0 1 3 0 is_stmt 0 # test.c:3:0
+; X64:      .cv_loc 0 1 3 0 # test.c:3:0
 ; X64:      # %bb.
 ; X64:      subq    $40, %rsp
 ; X64:      .cv_loc 0 1 4 2 # test.c:4:2




More information about the llvm-commits mailing list