[llvm] r348279 - Revert "Adapt gcov to changes in CFE."

Ilya Biryukov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 4 08:30:31 PST 2018


Author: ibiryukov
Date: Tue Dec  4 08:30:31 2018
New Revision: 348279

URL: http://llvm.org/viewvc/llvm-project?rev=348279&view=rev
Log:
Revert "Adapt gcov to changes in CFE."

This reverts commit r348203.
Reason: this produces absolute paths in .gcno files, breaking us
internally as we rely on them being consistent with the filenames passed
in the command line.

Also reverts r348157 and r348155 to account for revert of r348154 in
clang repository.

Modified:
    llvm/trunk/include/llvm/IR/DiagnosticInfo.h
    llvm/trunk/lib/IR/DiagnosticInfo.cpp
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
    llvm/trunk/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll

Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=348279&r1=348278&r2=348279&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Tue Dec  4 08:30:31 2018
@@ -340,7 +340,7 @@ private:
 };
 
 class DiagnosticLocation {
-  DIFile *File = nullptr;
+  StringRef Filename;
   unsigned Line = 0;
   unsigned Column = 0;
 
@@ -349,11 +349,8 @@ public:
   DiagnosticLocation(const DebugLoc &DL);
   DiagnosticLocation(const DISubprogram *SP);
 
-  bool isValid() const { return File; }
-  /// Return the full path to the file.
-  std::string getAbsolutePath() const;
-  /// Return the file name relative to the compilation directory.
-  StringRef getRelativePath() const;
+  bool isValid() const { return !Filename.empty(); }
+  StringRef getFilename() const { return Filename; }
   unsigned getLine() const { return Line; }
   unsigned getColumn() const { return Column; }
 };
@@ -378,13 +375,9 @@ public:
   const std::string getLocationStr() const;
 
   /// Return location information for this diagnostic in three parts:
-  /// the relative source file path, line number and column.
-  void getLocation(StringRef &RelativePath, unsigned &Line,
-                   unsigned &Column) const;
-
-  /// Return the absolute path tot the file.
-  std::string getAbsolutePath() const;
-  
+  /// the source file name, line number and column.
+  void getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const;
+
   const Function &getFunction() const { return Fn; }
   DiagnosticLocation getLocation() const { return Loc; }
 

Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=348279&r1=348278&r2=348279&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Tue Dec  4 08:30:31 2018
@@ -33,10 +33,9 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include <atomic>
 #include <cassert>
 #include <memory>
@@ -107,7 +106,7 @@ void DiagnosticInfoPGOProfile::print(Dia
 DiagnosticLocation::DiagnosticLocation(const DebugLoc &DL) {
   if (!DL)
     return;
-  File = DL->getFile();
+  Filename = DL->getFilename();
   Line = DL->getLine();
   Column = DL->getColumn();
 }
@@ -115,36 +114,17 @@ DiagnosticLocation::DiagnosticLocation(c
 DiagnosticLocation::DiagnosticLocation(const DISubprogram *SP) {
   if (!SP)
     return;
-  
-  File = SP->getFile();
+  Filename = SP->getFilename();
   Line = SP->getScopeLine();
   Column = 0;
 }
 
-StringRef DiagnosticLocation::getRelativePath() const {
-  return File->getFilename();
-}
-
-std::string DiagnosticLocation::getAbsolutePath() const {
-  StringRef Name = File->getFilename();
-  if (sys::path::is_absolute(Name))
-    return Name;
-
-  SmallString<128> Path;
-  sys::path::append(Path, File->getDirectory(), Name);
-  return sys::path::remove_leading_dotslash(Path).str();
-}
-
-std::string DiagnosticInfoWithLocationBase::getAbsolutePath() const {
-  return Loc.getAbsolutePath();
-}
-
-void DiagnosticInfoWithLocationBase::getLocation(StringRef &RelativePath,
-                                                 unsigned &Line,
-                                                 unsigned &Column) const {
-  RelativePath = Loc.getRelativePath();
-  Line = Loc.getLine();
-  Column = Loc.getColumn();
+void DiagnosticInfoWithLocationBase::getLocation(StringRef *Filename,
+                                                 unsigned *Line,
+                                                 unsigned *Column) const {
+  *Filename = Loc.getFilename();
+  *Line = Loc.getLine();
+  *Column = Loc.getColumn();
 }
 
 const std::string DiagnosticInfoWithLocationBase::getLocationStr() const {
@@ -152,7 +132,7 @@ const std::string DiagnosticInfoWithLoca
   unsigned Line = 0;
   unsigned Column = 0;
   if (isLocationAvailable())
-    getLocation(Filename, Line, Column);
+    getLocation(&Filename, &Line, &Column);
   return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
 }
 
@@ -419,7 +399,7 @@ template <> struct MappingTraits<Diagnos
   static void mapping(IO &io, DiagnosticLocation &DL) {
     assert(io.outputting() && "input not yet implemented");
 
-    StringRef File = DL.getRelativePath();
+    StringRef File = DL.getFilename();
     unsigned Line = DL.getLine();
     unsigned Col = DL.getColumn();
 

Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=348279&r1=348278&r2=348279&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Tue Dec  4 08:30:31 2018
@@ -180,12 +180,6 @@ static StringRef getFunctionName(const D
   return SP->getName();
 }
 
-template<class DINode> SmallString<128> getFilename(const DINode *N) {
-  SmallString<128> Path;
-  sys::path::append(Path, N->getDirectory(), N->getFilename());
-  return Path;
-}
-
 namespace {
   class GCOVRecord {
    protected:
@@ -262,7 +256,7 @@ namespace {
     }
 
    private:
-    std::string Filename;
+    StringRef Filename;
     SmallVector<uint32_t, 32> Lines;
   };
 
@@ -383,9 +377,8 @@ namespace {
 
     void writeOut() {
       writeBytes(FunctionTag, 4);
-      SmallString<128> Filename = getFilename(SP);
       uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +
-                          1 + lengthOfGCOVString(Filename) + 1;
+                          1 + lengthOfGCOVString(SP->getFilename()) + 1;
       if (UseCfgChecksum)
         ++BlockLen;
       write(BlockLen);
@@ -394,7 +387,7 @@ namespace {
       if (UseCfgChecksum)
         write(CfgChecksum);
       writeGCOVString(getFunctionName(SP));
-      writeGCOVString(Filename);
+      writeGCOVString(SP->getFilename());
       write(SP->getLine());
 
       // Emit count of blocks.
@@ -473,7 +466,7 @@ bool GCOVProfiler::isFunctionInstrumente
   if (FilterRe.empty() && ExcludeRe.empty()) {
     return true;
   }
-  SmallString<128> Filename = getFilename(F.getSubprogram());
+  const StringRef Filename = F.getSubprogram()->getFilename();
   auto It = InstrumentedFiles.find(Filename);
   if (It != InstrumentedFiles.end()) {
     return It->second;
@@ -538,7 +531,7 @@ std::string GCOVProfiler::mangleName(con
     }
   }
 
-  SmallString<128> Filename = getFilename(CU);
+  SmallString<128> Filename = CU->getFilename();
   sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
   StringRef FName = sys::path::filename(Filename);
   SmallString<128> CurPath;
@@ -695,8 +688,7 @@ void GCOVProfiler::emitProfileNotes() {
       // Add the function line number to the lines of the entry block
       // to have a counter for the function definition.
       uint32_t Line = SP->getLine();
-      auto Filename = getFilename(SP);
-      Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
+      Func.getBlock(&EntryBlock).getFile(SP->getFilename()).addLine(Line);
 
       for (auto &BB : F) {
         GCOVBlock &Block = Func.getBlock(&BB);
@@ -727,7 +719,7 @@ void GCOVProfiler::emitProfileNotes() {
           if (SP != getDISubprogram(Loc.getScope()))
             continue;
 
-          GCOVLines &Lines = Block.getFile(Filename);
+          GCOVLines &Lines = Block.getFile(SP->getFilename());
           Lines.addLine(Loc.getLine());
         }
         Line = 0;

Modified: llvm/trunk/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll?rev=348279&r1=348278&r2=348279&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll Tue Dec  4 08:30:31 2018
@@ -17,7 +17,7 @@ attributes #1 = { nounwind }
 !llvm.module.flags = !{!2, !3}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_OpenCL, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
-!1 = !DIFile(filename: "foo.cl", directory: ".")
+!1 = !DIFile(filename: "foo.cl", directory: "/dev/null")
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !DILocation(line: 1, column: 42, scope: !5)




More information about the llvm-commits mailing list