Skip to content

Commit afa0acf

Browse files
committed
[llvm-debuginfo-analyzer][debuginfologicalview] Make LVObject::ID unconditional
Make the `LVObject::ID` member unconditional on `NDEBUG` or `LLVM_ENABLE_ABI_BREAKING_CHECKS`. Changing size of `ScopeLevel` (uint16_t) and `ID` (uint32_t) and careful reorder of data members in LVObject (avoding unneeded padding) leaves `sizeof(LVObject)` unchanged.
1 parent a77d44d commit afa0acf

File tree

4 files changed

+13
-36
lines changed

4 files changed

+13
-36
lines changed

llvm/docs/CommandGuide/llvm-debuginfo-analyzer.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,7 @@ INTERNAL
676676
Typically these kind of options are available only in *debug* builds.
677677

678678
:program:`llvm-debuginfo-analyzer` supports these advanced options in
679-
both *release* and *debug* builds, with the exception of the unique ID
680-
that is generated only in *debug* builds.
679+
both *release* and *debug* builds.
681680

682681
.. option:: --internal=<value[,value,...]>
683682

llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOBJECT_H
1616

1717
#include "llvm/BinaryFormat/Dwarf.h"
18-
#include "llvm/Config/abi-breaking.h"
1918
#include "llvm/DebugInfo/CodeView/CodeView.h"
2019
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
2120
#include "llvm/DebugInfo/LogicalView/Core/LVSupport.h"
@@ -37,7 +36,7 @@ namespace logicalview {
3736
using LVSectionIndex = uint64_t;
3837
using LVAddress = uint64_t;
3938
using LVHalf = uint16_t;
40-
using LVLevel = uint32_t;
39+
using LVLevel = uint16_t;
4140
using LVOffset = uint64_t;
4241
using LVSigned = int64_t;
4342
using LVUnsigned = uint64_t;
@@ -130,8 +129,6 @@ class LLVM_ABI LVObject {
130129
HasCodeViewLocation, // CodeView object with debug location.
131130
LastEntry
132131
};
133-
// Typed bitvector with properties for this object.
134-
LVProperties<Property> Properties;
135132

136133
LVOffset Offset = 0;
137134
uint32_t LineNumber = 0;
@@ -141,6 +138,14 @@ class LLVM_ABI LVObject {
141138
dwarf::Attribute Attr;
142139
LVSmall Opcode;
143140
} TagAttrOpcode = {dwarf::DW_TAG_null};
141+
// Typed bitvector with properties for this object.
142+
LVProperties<Property> Properties;
143+
144+
// This is an internal ID used for debugging logical elements. It is used
145+
// for cases where an unique offset within the binary input file is not
146+
// available.
147+
static uint32_t GID;
148+
uint32_t ID = 0;
144149

145150
// The parent of this object (nullptr if the root scope). For locations,
146151
// the parent is a symbol object; otherwise it is a scope object.
@@ -156,9 +161,7 @@ class LLVM_ABI LVObject {
156161
// copy constructor to create that object; it is used to print a reference
157162
// to another object and in the case of templates, to print its encoded args.
158163
LVObject(const LVObject &Object) {
159-
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
160164
incID();
161-
#endif
162165
Properties = Object.Properties;
163166
Offset = Object.Offset;
164167
LineNumber = Object.LineNumber;
@@ -167,18 +170,10 @@ class LLVM_ABI LVObject {
167170
Parent = Object.Parent;
168171
}
169172

170-
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
171-
// This is an internal ID used for debugging logical elements. It is used
172-
// for cases where an unique offset within the binary input file is not
173-
// available.
174-
static uint64_t GID;
175-
uint64_t ID = 0;
176-
177173
void incID() {
178174
++GID;
179175
ID = GID;
180176
}
181-
#endif
182177

183178
protected:
184179
// Get a string representation for the given number and discriminator.
@@ -194,11 +189,7 @@ class LLVM_ABI LVObject {
194189
virtual void printFileIndex(raw_ostream &OS, bool Full = true) const {}
195190

196191
public:
197-
LVObject() {
198-
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
199-
incID();
200-
#endif
201-
};
192+
LVObject() { incID(); };
202193
LVObject &operator=(const LVObject &) = delete;
203194
virtual ~LVObject() = default;
204195

@@ -317,14 +308,7 @@ class LLVM_ABI LVObject {
317308
void dump() const { print(dbgs()); }
318309
#endif
319310

320-
uint64_t getID() const {
321-
return
322-
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
323-
ID;
324-
#else
325-
0;
326-
#endif
327-
}
311+
uint32_t getID() const { return ID; }
328312
};
329313

330314
} // end namespace logicalview

llvm/lib/DebugInfo/LogicalView/Core/LVObject.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ using namespace llvm::logicalview;
2121

2222
#define DEBUG_TYPE "Object"
2323

24-
#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
25-
uint64_t LVObject::GID = 0;
26-
#endif
24+
uint32_t LVObject::GID = 0;
2725

2826
StringRef llvm::logicalview::typeNone() { return StringRef(); }
2927
StringRef llvm::logicalview::typeVoid() { return "void"; }
@@ -137,10 +135,8 @@ void LVObject::printAttributes(raw_ostream &OS, bool Full, StringRef Name,
137135
}
138136

139137
void LVObject::printAttributes(raw_ostream &OS, bool Full) const {
140-
#ifndef NDEBUG
141138
if (options().getInternalID())
142139
OS << hexSquareString(getID());
143-
#endif
144140
if (options().getCompareExecute() &&
145141
(options().getAttributeAdded() || options().getAttributeMissing()))
146142
OS << (getIsAdded() ? '+' : getIsMissing() ? '-' : ' ');

llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,10 @@ void LVOptions::resolveDependencies() {
259259
}
260260

261261
void LVOptions::calculateIndentationSize() {
262-
#ifndef NDEBUG
263262
if (getInternalID()) {
264263
std::string String = hexSquareString(0);
265264
IndentationSize += String.length();
266265
}
267-
#endif
268266
if (getCompareExecute() && (getAttributeAdded() || getAttributeMissing()))
269267
++IndentationSize;
270268
if (getAttributeOffset()) {

0 commit comments

Comments
 (0)