diff options
author | Derek Schuff <dschuff@google.com> | 2016-03-29 20:28:20 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2016-03-29 20:28:20 +0000 |
commit | 07636cd5e7e029808c98f2cf2ebae8780986d877 (patch) | |
tree | b7c9f61d7ae62bf264fdba27eaf45f4ab72805a3 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 32071a20bc62e8992f1e0c218de8493a0c5604a7 (diff) | |
download | bcm5719-llvm-07636cd5e7e029808c98f2cf2ebae8780986d877.tar.gz bcm5719-llvm-07636cd5e7e029808c98f2cf2ebae8780986d877.zip |
Add a print method to MachineFunctionProperties for better error messages
This makes check failures much easier to understand.
Make it empty (but leave it in the class) for NDEBUG builds.
Differential Revision: http://reviews.llvm.org/D18529
llvm-svn: 264780
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index e93299fccb2..a8475d29827 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -54,6 +54,28 @@ static cl::opt<unsigned> void MachineFunctionInitializer::anchor() {} +void MachineFunctionProperties::print(raw_ostream &ROS) const { + // Leave this function even in NDEBUG as an out-of-line anchor. +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) + if (!Properties.any()) { + ROS << "(empty)"; + return; + } + for (BitVector::size_type i = 0; i < Properties.size(); ++i) { + if (Properties[i]) { + switch(static_cast<Property>(i)) { + case Property::AllVRegsAllocated: + ROS << "AllVRegsAllocated "; + break; + default: + // TODO: Implement IsSSA/TracksLiveness when we make them properties. + llvm_unreachable("Unexpected value for property enum"); + } + } + } +#endif +} + //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// @@ -370,6 +392,9 @@ StringRef MachineFunction::getName() const { void MachineFunction::print(raw_ostream &OS, SlotIndexes *Indexes) const { OS << "# Machine code for function " << getName() << ": "; + OS << "Properties: <"; + getProperties().print(OS); + OS << "> : "; if (RegInfo) { OS << (RegInfo->isSSA() ? "SSA" : "Post SSA"); if (!RegInfo->tracksLiveness()) |