Skip to content

Commit 4484370

Browse files
committed
Rebase fixes, move validateDbgValues into verifier
1 parent 1a72753 commit 4484370

File tree

3 files changed

+7
-77
lines changed

3 files changed

+7
-77
lines changed

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,6 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
9393
/// if necessary.
9494
void setIsNewDbgInfoFormat(bool NewFlag);
9595

96-
/// Validate any DPMarkers / DPValues attached to instructions in this block,
97-
/// and block-level stored data too (TrailingDPValues).
98-
/// \p Assert Should this method fire an assertion if a problem is found?
99-
/// \p Msg Should this method print a message to errs() if a problem is found?
100-
/// \p OS Output stream to write errors to.
101-
/// \returns True if a problem is found.
102-
bool validateDbgValues(bool Assert = true, bool Msg = false,
103-
raw_ostream *OS = nullptr);
104-
10596
/// Record that the collection of DPValues in \p M "trails" after the last
10697
/// instruction of this block. These are equivalent to dbg.value intrinsics
10798
/// that exist at the end of a basic block with no terminator (a transient

llvm/lib/IR/BasicBlock.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -122,67 +122,6 @@ void BasicBlock::convertFromNewDbgValues() {
122122
assert(!getTrailingDPValues());
123123
}
124124

125-
bool BasicBlock::validateDbgValues(bool Assert, bool Msg, raw_ostream *OS) {
126-
bool RetVal = false;
127-
if (!OS)
128-
OS = &errs();
129-
130-
// Helper lambda for reporting failures: via assertion, printing, and return
131-
// value.
132-
auto TestFailure = [Assert, Msg, &RetVal, OS](bool Val, const char *Text) {
133-
// Did the test fail?
134-
if (Val)
135-
return;
136-
137-
// If we're asserting, then fire off an assertion.
138-
if (Assert)
139-
llvm_unreachable(Text);
140-
141-
if (Msg)
142-
*OS << Text << "\n";
143-
RetVal = true;
144-
};
145-
146-
// We should have the same debug-format as the parent function.
147-
TestFailure(getParent()->IsNewDbgInfoFormat == IsNewDbgInfoFormat,
148-
"Parent function doesn't have the same debug-info format");
149-
150-
// Only validate if we are using the new format.
151-
if (!IsNewDbgInfoFormat)
152-
return RetVal;
153-
154-
// Match every DPMarker to every Instruction and vice versa, and
155-
// verify that there are no invalid DPValues.
156-
for (auto It = begin(); It != end(); ++It) {
157-
if (!It->DbgMarker)
158-
continue;
159-
160-
// Validate DebugProgramMarkers.
161-
DPMarker *CurrentDebugMarker = It->DbgMarker;
162-
163-
// If this is a marker, it should match the instruction and vice versa.
164-
TestFailure(CurrentDebugMarker->MarkedInstr == &*It,
165-
"Debug Marker points to incorrect instruction?");
166-
167-
// Now validate any DPValues in the marker.
168-
for (DbgRecord &DPR : CurrentDebugMarker->getDbgValueRange()) {
169-
// Validate DebugProgramValues.
170-
TestFailure(DPR.getMarker() == CurrentDebugMarker,
171-
"Not pointing at correct next marker!");
172-
173-
// Verify that no DbgValues appear prior to PHIs.
174-
TestFailure(
175-
!isa<PHINode>(It),
176-
"DebugProgramValues must not appear before PHI nodes in a block!");
177-
}
178-
}
179-
180-
// Except transiently when removing + re-inserting the block terminator, there
181-
// should be no trailing DPValues.
182-
TestFailure(!getTrailingDPValues(), "Trailing DPValues in block");
183-
return RetVal;
184-
}
185-
186125
#ifndef NDEBUG
187126
void BasicBlock::dumpDbgValues() const {
188127
for (auto &Inst : *this) {

llvm/lib/IR/Verifier.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ struct VerifierSupport {
173173
}
174174
}
175175

176+
void Write(const DbgRecord *DR) {
177+
if (DR)
178+
DR->print(*OS, MST, false);
179+
}
180+
176181
void Write(const DPValue *V) {
177182
if (V)
178183
V->print(*OS, MST, false);
@@ -676,7 +681,7 @@ void Verifier::visitDbgRecords(Instruction &I) {
676681
return;
677682
CheckDI(I.DbgMarker->MarkedInstr == &I, "Instruction has invalid DbgMarker", &I);
678683
CheckDI(!isa<PHINode>(&I) || !I.hasDbgValues(), "PHI Node must not have any attached DbgRecords", &I);
679-
for (auto &DPV : I.getDbgValueRange()) {
684+
for (DPValue &DPV : DPValue::filter(I.getDbgValueRange())) {
680685
CheckDI(DPV.getMarker() == I.DbgMarker, "DbgRecord had invalid DbgMarker", &I, &DPV);
681686
visit(DPV);
682687
}
@@ -3010,13 +3015,8 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
30103015
}
30113016

30123017
// Confirm that no issues arise from the debug program.
3013-
if (BB.IsNewDbgInfoFormat) {
3018+
if (BB.IsNewDbgInfoFormat)
30143019
CheckDI(!BB.getTrailingDPValues(), "Basic Block has trailing DbgRecords!", &BB);
3015-
// Configure the validate function to not fire assertions, instead print
3016-
// errors and return true if there's a problem.
3017-
bool RetVal = BB.validateDbgValues(false, true, OS);
3018-
Check(!RetVal, "Invalid configuration of new-debug-info data found");
3019-
}
30203020
}
30213021

30223022
void Verifier::visitTerminator(Instruction &I) {

0 commit comments

Comments
 (0)