Skip to content

Commit 7c63b5a

Browse files
authored
Merge pull request swiftlang#38295 from gottesmm/pr-bfd321622f3300495b5fccb815cbe1383268f64b
[sil] Add a dump method for operand for use in the debugger.
2 parents ca26a1a + ff93442 commit 7c63b5a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/swift/SIL/SILValue.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,11 @@ class Operand {
10501050
SILBasicBlock *getParentBlock() const;
10511051
SILFunction *getParentFunction() const;
10521052

1053+
LLVM_ATTRIBUTE_DEPRECATED(
1054+
void dump() const LLVM_ATTRIBUTE_USED,
1055+
"Dump the operand's state. Only for use in the debugger!");
1056+
void print(llvm::raw_ostream &os) const;
1057+
10531058
private:
10541059
void removeFromCurrent() {
10551060
if (!Back)

lib/SIL/IR/SILValue.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ bool Operand::isConsuming() const {
347347
return get().getOwnershipKind() != OwnershipKind::None;
348348
}
349349

350+
void Operand::dump() const { print(llvm::dbgs()); }
351+
352+
void Operand::print(llvm::raw_ostream &os) const {
353+
os << "Operand.\n"
354+
"Owner: "
355+
<< *Owner << "Value: " << get() << "Operand Number: " << getOperandNumber()
356+
<< '\n'
357+
<< "Is Type Dependent: " << (isTypeDependent() ? "yes" : "no") << '\n';
358+
}
359+
350360
//===----------------------------------------------------------------------===//
351361
// OperandConstraint
352362
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)