Skip to content

Commit 11f7c89

Browse files
committed
Revert "[NFC] Add fragment-getting functions to DbgRecord (#97705)"
This reverts commit f21b62b. Fails to build.
1 parent 40fe73e commit 11f7c89

File tree

4 files changed

+23
-63
lines changed

4 files changed

+23
-63
lines changed

llvm/include/llvm/IR/DbgVariableFragmentInfo.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "llvm/ADT/StringRef.h"
2222
#include "llvm/ADT/iterator_range.h"
2323
#include "llvm/IR/Constants.h"
24-
#include "llvm/IR/DbgVariableFragmentInfo.h"
2524
#include "llvm/IR/Metadata.h"
2625
#include "llvm/IR/PseudoProbe.h"
2726
#include "llvm/Support/Casting.h"
@@ -2887,7 +2886,29 @@ class DIExpression : public MDNode {
28872886
/// Return whether there is exactly one operator and it is a DW_OP_deref;
28882887
bool isDeref() const;
28892888

2890-
using FragmentInfo = DbgVariableFragmentInfo;
2889+
/// Holds the characteristics of one fragment of a larger variable.
2890+
struct FragmentInfo {
2891+
FragmentInfo() = default;
2892+
FragmentInfo(uint64_t SizeInBits, uint64_t OffsetInBits)
2893+
: SizeInBits(SizeInBits), OffsetInBits(OffsetInBits) {}
2894+
uint64_t SizeInBits;
2895+
uint64_t OffsetInBits;
2896+
/// Return the index of the first bit of the fragment.
2897+
uint64_t startInBits() const { return OffsetInBits; }
2898+
/// Return the index of the bit after the end of the fragment, e.g. for
2899+
/// fragment offset=16 and size=32 return their sum, 48.
2900+
uint64_t endInBits() const { return OffsetInBits + SizeInBits; }
2901+
2902+
/// Returns a zero-sized fragment if A and B don't intersect.
2903+
static DIExpression::FragmentInfo intersect(DIExpression::FragmentInfo A,
2904+
DIExpression::FragmentInfo B) {
2905+
uint64_t StartInBits = std::max(A.OffsetInBits, B.OffsetInBits);
2906+
uint64_t EndInBits = std::min(A.endInBits(), B.endInBits());
2907+
if (EndInBits <= StartInBits)
2908+
return {0, 0};
2909+
return DIExpression::FragmentInfo(EndInBits - StartInBits, StartInBits);
2910+
}
2911+
};
28912912

28922913
/// Return the number of bits that have an active value, i.e. those that
28932914
/// aren't known to be zero/sign (depending on the type of Var) and which

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "llvm/ADT/ilist.h"
5151
#include "llvm/ADT/ilist_node.h"
5252
#include "llvm/ADT/iterator.h"
53-
#include "llvm/IR/DbgVariableFragmentInfo.h"
5453
#include "llvm/IR/DebugLoc.h"
5554
#include "llvm/IR/Instruction.h"
5655
#include "llvm/IR/SymbolTableListTraits.h"
@@ -461,17 +460,6 @@ class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
461460
resetDebugValue(0, NewLocation);
462461
}
463462

464-
std::optional<DbgVariableFragmentInfo> getFragment() const;
465-
/// Get the FragmentInfo for the variable if it exists, otherwise return a
466-
/// FragmentInfo that covers the entire variable if the variable size is
467-
/// known, otherwise return a zero-sized fragment.
468-
DbgVariableFragmentInfo getFragmentOrEntireVariable() const {
469-
if (auto Frag = getFragment())
470-
return *Frag;
471-
if (auto Sz = getVariable()->getSizeInBits())
472-
return {*Sz, 0};
473-
return {0, 0};
474-
}
475463
/// Get the size (in bits) of the variable, or fragment of the variable that
476464
/// is described.
477465
std::optional<uint64_t> getFragmentSizeInBits() const;

llvm/lib/IR/DebugProgramInstruction.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ bool DbgVariableRecord::isKillLocation() const {
371371
any_of(location_ops(), [](Value *V) { return isa<UndefValue>(V); });
372372
}
373373

374-
std::optional<DbgVariableFragmentInfo> DbgVariableRecord::getFragment() const {
375-
return getExpression()->getFragmentInfo();
376-
}
377-
378374
std::optional<uint64_t> DbgVariableRecord::getFragmentSizeInBits() const {
379375
if (auto Fragment = getExpression()->getFragmentInfo())
380376
return Fragment->SizeInBits;

0 commit comments

Comments
 (0)