[PATCH] D59303: [DebugInfo] Pass all values in DebugLocEntry's constructor, NFC
David Stenberg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 15:41:35 PDT 2019
dstenb updated this revision to Diff 190522.
dstenb added a comment.
Herald added a subscriber: hiraditya.
Move lambda expression back into assert() to avoid -Wunused-variable warning in non-assert builds.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59303/new/
https://reviews.llvm.org/D59303
Files:
llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1121,7 +1121,7 @@
continue;
}
- // If this fragment overlaps with any open ranges, truncate them.
+ // If this debug value overlaps with any open ranges, truncate them.
const DIExpression *DIExpr = Begin->getDebugExpression();
auto Last = remove_if(OpenRanges, [&](DebugLocEntry::Value R) {
return DIExpr->fragmentsOverlap(R.getExpression());
@@ -1143,30 +1143,15 @@
LLVM_DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n");
auto Value = getDebugLocValue(Begin);
+ OpenRanges.push_back(Value);
// Omit entries with empty ranges as they do not have any effect in DWARF.
if (StartLabel == EndLabel) {
- // If this is a fragment, we must still add the value to the list of
- // open ranges, since it may describe non-overlapping parts of the
- // variable.
- if (DIExpr->isFragment())
- OpenRanges.push_back(Value);
LLVM_DEBUG(dbgs() << "Omitting location list entry with empty range.\n");
continue;
}
- DebugLocEntry Loc(StartLabel, EndLabel, Value);
-
- if (DIExpr->isFragment()) {
- // Add this value to the list of open ranges.
- OpenRanges.push_back(Value);
- }
-
- // Add all values from still valid non-overlapping fragments.
- if (OpenRanges.size())
- Loc.addValues(OpenRanges);
-
- DebugLoc.push_back(std::move(Loc));
+ DebugLoc.emplace_back(StartLabel, EndLabel, OpenRanges);
// Attempt to coalesce the ranges of two otherwise identical
// DebugLocEntries.
@@ -1906,6 +1891,8 @@
void DebugLocEntry::finalize(const AsmPrinter &AP,
DebugLocStream::ListBuilder &List,
const DIBasicType *BT) {
+ assert(!Values.empty() &&
+ "location list entries without values are redundant");
assert(Begin != End && "unexpected location list entry with empty range");
DebugLocStream::EntryBuilder Entry(List, Begin, End);
BufferByteStreamer Streamer = Entry.getStreamer();
Index: llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -100,9 +100,9 @@
SmallVector<Value, 1> Values;
public:
- DebugLocEntry(const MCSymbol *B, const MCSymbol *E, Value Val)
+ DebugLocEntry(const MCSymbol *B, const MCSymbol *E, ArrayRef<Value> Vals)
: Begin(B), End(E) {
- Values.push_back(std::move(Val));
+ addValues(Vals);
}
/// Attempt to merge this DebugLocEntry with Next and return
@@ -124,9 +124,10 @@
void addValues(ArrayRef<DebugLocEntry::Value> Vals) {
Values.append(Vals.begin(), Vals.end());
sortUniqueValues();
- assert(all_of(Values, [](DebugLocEntry::Value V) {
- return V.isFragment();
- }) && "value must be a piece");
+ assert((Values.size() == 1 ||
+ all_of(Values,
+ [](DebugLocEntry::Value V) { return V.isFragment(); })) &&
+ "must either have a single value or multiple pieces");
}
// Sort the pieces by offset.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59303.190522.patch
Type: text/x-patch
Size: 3327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190313/429e4b91/attachment.bin>
More information about the llvm-commits
mailing list