[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 02:15:08 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 5f05d5ec8f9bb15c0ac29fce843a2c73165ac414 194069a26418fc4dbb27cee13d5b4263588320b7 --extensions inc,h,cpp -- clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/IR/DebugLoc.h llvm/include/llvm/Support/Signals.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/CodeGen/BranchFolding.cpp llvm/lib/CodeGen/BranchFolding.h llvm/lib/IR/DebugInfo.cpp llvm/lib/IR/DebugLoc.cpp llvm/lib/IR/Instruction.cpp llvm/lib/Support/Signals.cpp llvm/lib/Support/Unix/Signals.inc llvm/lib/Support/Windows/Signals.inc llvm/lib/Transforms/Utils/Debugify.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/IR/DebugLoc.h b/llvm/include/llvm/IR/DebugLoc.h
index 5f45d853a9..1812cf4205 100644
--- a/llvm/include/llvm/IR/DebugLoc.h
+++ b/llvm/include/llvm/IR/DebugLoc.h
@@ -70,12 +70,14 @@ namespace llvm {
   // Currently we only need to track the Origin of this DILoc when using a
   // DebugLoc that is Normal and empty, so only collect the origin stacktrace in
   // those cases.
-  class DILocAndCoverageTracking : public TrackingMDNodeRef, public DbgLocOrigin {
+  class DILocAndCoverageTracking : public TrackingMDNodeRef,
+                                   public DbgLocOrigin {
   public:
     DebugLocKind Kind;
     // Default constructor for empty DebugLocs.
     DILocAndCoverageTracking()
-        : TrackingMDNodeRef(nullptr), DbgLocOrigin(true), Kind(DebugLocKind::Normal) {}
+        : TrackingMDNodeRef(nullptr), DbgLocOrigin(true),
+          Kind(DebugLocKind::Normal) {}
     // Valid or nullptr MDNode*, normal DebugLocKind
     DILocAndCoverageTracking(const MDNode *Loc)
         : TrackingMDNodeRef(const_cast<MDNode *>(Loc)), DbgLocOrigin(!Loc),
@@ -83,7 +85,8 @@ namespace llvm {
     DILocAndCoverageTracking(const DILocation *Loc);
     // Always nullptr MDNode*, any DebugLocKind
     DILocAndCoverageTracking(DebugLocKind Kind)
-        : TrackingMDNodeRef(nullptr), DbgLocOrigin(Kind == DebugLocKind::Normal), Kind(Kind) {}
+        : TrackingMDNodeRef(nullptr),
+          DbgLocOrigin(Kind == DebugLocKind::Normal), Kind(Kind) {}
   };
   template <> struct simplify_type<DILocAndCoverageTracking> {
     using SimpleType = MDNode *;
@@ -137,7 +140,7 @@ namespace llvm {
 
 #if ENABLE_DEBUGLOC_ORIGIN_TRACKING
 #if !ENABLE_DEBUGLOC_COVERAGE_TRACKING
-  #error Cannot enable DebugLoc origin-tracking without coverage-tracking!
+#error Cannot enable DebugLoc origin-tracking without coverage-tracking!
 #endif
 
     const DbgLocOrigin::StackTracesTy &getOriginStackTraces() const {
diff --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp
index 9ad1d58dc5..ad02cd078d 100644
--- a/llvm/lib/IR/DebugLoc.cpp
+++ b/llvm/lib/IR/DebugLoc.cpp
@@ -26,7 +26,7 @@ void DbgLocOrigin::addTrace() {
   auto &[Depth, StackTrace] = StackTraces.emplace_back();
   Depth = sys::getStackTrace(StackTrace);
 }
-}
+} // namespace llvm
 #endif
 
 using namespace llvm;
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 00a6c92f88..5b358cae1d 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -503,14 +503,14 @@ static bool checkInstructions(const DebugInstMap &DILocsBefore,
     auto InstName = Instruction::getOpcodeName(Instr->getOpcode());
 
     auto CreateJSONBugEntry = [&](const char *Action) {
-      Bugs.push_back(
-          llvm::json::Object({{"metadata", "DILocation"},
-                              {"fn-name", FnName.str()},
-                              {"bb-name", BBName.str()},
-                              {"instr", InstName},
-                              {"action", Action},
+      Bugs.push_back(llvm::json::Object({
+          {"metadata", "DILocation"},
+          {"fn-name", FnName.str()},
+          {"bb-name", BBName.str()},
+          {"instr", InstName},
+          {"action", Action},
 #if ENABLE_DEBUGLOC_ORIGIN_TRACKING
-                              {"origin", symbolizeStackTrace(Instr)},
+          {"origin", symbolizeStackTrace(Instr)},
 #endif
       }));
     };

``````````

</details>


https://github.com/llvm/llvm-project/pull/107369


More information about the cfe-commits mailing list