Index: llvm/trunk/include/llvm/CodeGen/MachineFunction.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h @@ -143,6 +143,8 @@ return !V.Properties.test(Properties); } + void print(raw_ostream &ROS) const; + private: BitVector Properties = BitVector(static_cast(Property::LastProperty)); Index: llvm/trunk/lib/CodeGen/MachineFunction.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp @@ -54,6 +54,28 @@ 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(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 @@ 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()) Index: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp @@ -44,8 +44,18 @@ MachineFunction &MF = getAnalysis().getMF(); MachineFunctionProperties &MFProps = MF.getProperties(); - assert(MFProps.verifyRequiredProperties(RequiredProperties) && - "Properties required by the pass are not met by the function"); +#ifndef NDEBUG + if (!MFProps.verifyRequiredProperties(RequiredProperties)) { + errs() << "MachineFunctionProperties required by " << getPassName() + << " pass are not met by function " << F.getName() << ".\n" + << "Required properties: "; + RequiredProperties.print(errs()); + errs() << "\nCurrent properties: "; + MFProps.print(errs()); + errs() << "\n"; + llvm_unreachable("MachineFunctionProperties check failed"); + } +#endif bool RV = runOnMachineFunction(MF);