[llvm] 11f7c89 - Revert "[NFC] Add fragment-getting functions to DbgRecord (#97705)"

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 01:20:59 PDT 2024


Author: Nikita Popov
Date: 2024-07-08T10:18:36+02:00
New Revision: 11f7c89bef14f57e36ed74a0fc647f214b1e058e

URL: https://github.com/llvm/llvm-project/commit/11f7c89bef14f57e36ed74a0fc647f214b1e058e
DIFF: https://github.com/llvm/llvm-project/commit/11f7c89bef14f57e36ed74a0fc647f214b1e058e.diff

LOG: Revert "[NFC] Add fragment-getting functions to DbgRecord (#97705)"

This reverts commit f21b62b0d1d13fa3f259da4dde587c1289c84fb8.

Fails to build.

Added: 
    

Modified: 
    llvm/include/llvm/IR/DebugInfoMetadata.h
    llvm/include/llvm/IR/DebugProgramInstruction.h
    llvm/lib/IR/DebugProgramInstruction.cpp

Removed: 
    llvm/include/llvm/IR/DbgVariableFragmentInfo.h


################################################################################
diff  --git a/llvm/include/llvm/IR/DbgVariableFragmentInfo.h b/llvm/include/llvm/IR/DbgVariableFragmentInfo.h
deleted file mode 100644
index 40326d5792f9f9..00000000000000
--- a/llvm/include/llvm/IR/DbgVariableFragmentInfo.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//===- llvm/IR/DbgVariableFragmentInfo.h ------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Helper struct to describe a fragment of a debug variable.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_IR_DBGVARIABLEFRAGMENTINFO_H
-#define LLVM_IR_DBGVARIABLEFRAGMENTINFO_H
-
-#include <cstdint>
-
-namespace llvm {
-struct DbgVariableFragmentInfo {
-  DbgVariableFragmentInfo() = default;
-  DbgVariableFragmentInfo(uint64_t SizeInBits, uint64_t OffsetInBits)
-      : SizeInBits(SizeInBits), OffsetInBits(OffsetInBits) {}
-  uint64_t SizeInBits;
-  uint64_t OffsetInBits;
-  /// Return the index of the first bit of the fragment.
-  uint64_t startInBits() const { return OffsetInBits; }
-  /// Return the index of the bit after the end of the fragment, e.g. for
-  /// fragment offset=16 and size=32 return their sum, 48.
-  uint64_t endInBits() const { return OffsetInBits + SizeInBits; }
-
-  /// Returns a zero-sized fragment if A and B don't intersect.
-  static DbgVariableFragmentInfo intersect(DbgVariableFragmentInfo A,
-                                           DbgVariableFragmentInfo B) {
-    // Don't use std::max or min to avoid including <algorithm>.
-    uint64_t StartInBits =
-        A.OffsetInBits > B.OffsetInBits ? A.OffsetInBits : B.OffsetInBits;
-    uint64_t EndInBits =
-        A.endInBits() < B.endInBits() ? A.endInBits() : B.endInBits();
-    if (EndInBits <= StartInBits)
-      return {0, 0};
-    return DbgVariableFragmentInfo(EndInBits - StartInBits, StartInBits);
-  }
-};
-} // end namespace llvm
-
-#endif // LLVM_IR_DBGVARIABLEFRAGMENTINFO_H

diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index d953ce46efb309..524945862e8d42 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -21,7 +21,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/IR/Constants.h"
-#include "llvm/IR/DbgVariableFragmentInfo.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/PseudoProbe.h"
 #include "llvm/Support/Casting.h"
@@ -2887,7 +2886,29 @@ class DIExpression : public MDNode {
   /// Return whether there is exactly one operator and it is a DW_OP_deref;
   bool isDeref() const;
 
-  using FragmentInfo = DbgVariableFragmentInfo;
+  /// Holds the characteristics of one fragment of a larger variable.
+  struct FragmentInfo {
+    FragmentInfo() = default;
+    FragmentInfo(uint64_t SizeInBits, uint64_t OffsetInBits)
+        : SizeInBits(SizeInBits), OffsetInBits(OffsetInBits) {}
+    uint64_t SizeInBits;
+    uint64_t OffsetInBits;
+    /// Return the index of the first bit of the fragment.
+    uint64_t startInBits() const { return OffsetInBits; }
+    /// Return the index of the bit after the end of the fragment, e.g. for
+    /// fragment offset=16 and size=32 return their sum, 48.
+    uint64_t endInBits() const { return OffsetInBits + SizeInBits; }
+
+    /// Returns a zero-sized fragment if A and B don't intersect.
+    static DIExpression::FragmentInfo intersect(DIExpression::FragmentInfo A,
+                                                DIExpression::FragmentInfo B) {
+      uint64_t StartInBits = std::max(A.OffsetInBits, B.OffsetInBits);
+      uint64_t EndInBits = std::min(A.endInBits(), B.endInBits());
+      if (EndInBits <= StartInBits)
+        return {0, 0};
+      return DIExpression::FragmentInfo(EndInBits - StartInBits, StartInBits);
+    }
+  };
 
   /// Return the number of bits that have an active value, i.e. those that
   /// aren't known to be zero/sign (depending on the type of Var) and which

diff  --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h
index 734a637a4a0ee2..ed8081a3cad197 100644
--- a/llvm/include/llvm/IR/DebugProgramInstruction.h
+++ b/llvm/include/llvm/IR/DebugProgramInstruction.h
@@ -50,7 +50,6 @@
 #include "llvm/ADT/ilist.h"
 #include "llvm/ADT/ilist_node.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/IR/DbgVariableFragmentInfo.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/SymbolTableListTraits.h"
@@ -461,17 +460,6 @@ class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
     resetDebugValue(0, NewLocation);
   }
 
-  std::optional<DbgVariableFragmentInfo> getFragment() const;
-  /// Get the FragmentInfo for the variable if it exists, otherwise return a
-  /// FragmentInfo that covers the entire variable if the variable size is
-  /// known, otherwise return a zero-sized fragment.
-  DbgVariableFragmentInfo getFragmentOrEntireVariable() const {
-    if (auto Frag = getFragment())
-      return *Frag; 
-    if (auto Sz = getVariable()->getSizeInBits())
-      return {*Sz, 0};
-    return {0, 0};
-  }
   /// Get the size (in bits) of the variable, or fragment of the variable that
   /// is described.
   std::optional<uint64_t> getFragmentSizeInBits() const;

diff  --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp
index 362d467beeb11b..21a7a55d067609 100644
--- a/llvm/lib/IR/DebugProgramInstruction.cpp
+++ b/llvm/lib/IR/DebugProgramInstruction.cpp
@@ -371,10 +371,6 @@ bool DbgVariableRecord::isKillLocation() const {
          any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
 }
 
-std::optional<DbgVariableFragmentInfo> DbgVariableRecord::getFragment() const {
-  return getExpression()->getFragmentInfo();
-}
-
 std::optional<uint64_t> DbgVariableRecord::getFragmentSizeInBits() const {
   if (auto Fragment = getExpression()->getFragmentInfo())
     return Fragment->SizeInBits;


        


More information about the llvm-commits mailing list