Index: llvm/trunk/lib/CodeGen/MachineVerifier.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp @@ -251,6 +251,7 @@ void verifyStackFrame(); void verifySlotIndexes() const; + void verifyProperties(const MachineFunction &MF); }; struct MachineVerifierPass : public MachineFunctionPass { @@ -307,6 +308,19 @@ } } +void MachineVerifier::verifyProperties(const MachineFunction &MF) { + // If a pass has introduced virtual registers without clearing the + // AllVRegsAllocated property (or set it without allocating the vregs) + // then report an error. + if (MF.getProperties().hasProperty( + MachineFunctionProperties::Property::AllVRegsAllocated) && + MRI->getNumVirtRegs()) { + report( + "Function has AllVRegsAllocated property but there are VReg operands", + &MF); + } +} + unsigned MachineVerifier::verify(MachineFunction &MF) { foundErrors = 0; @@ -331,6 +345,8 @@ verifySlotIndexes(); + verifyProperties(MF); + visitMachineFunctionBefore(); for (MachineFunction::const_iterator MFI = MF.begin(), MFE = MF.end(); MFI!=MFE; ++MFI) { Index: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp =================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp @@ -83,11 +83,6 @@ /// RABasic analysis usage. void getAnalysisUsage(AnalysisUsage &AU) const override; - MachineFunctionProperties getSetProperties() const override { - return MachineFunctionProperties().set( - MachineFunctionProperties::Property::AllVRegsAllocated); - } - void releaseMemory() override; Spiller &spiller() override { return *SpillerInstance; } Index: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp =================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp @@ -322,10 +322,6 @@ /// RAGreedy analysis usage. void getAnalysisUsage(AnalysisUsage &AU) const override; - MachineFunctionProperties getSetProperties() const override { - return MachineFunctionProperties().set( - MachineFunctionProperties::Property::AllVRegsAllocated); - } void releaseMemory() override; Spiller &spiller() override { return *SpillerInstance; } void enqueue(LiveInterval *LI) override; Index: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp =================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp @@ -106,11 +106,6 @@ /// PBQP analysis usage. void getAnalysisUsage(AnalysisUsage &au) const override; - MachineFunctionProperties getSetProperties() const override { - return MachineFunctionProperties().set( - MachineFunctionProperties::Property::AllVRegsAllocated); - } - /// Perform register allocation bool runOnMachineFunction(MachineFunction &MF) override; Index: llvm/trunk/lib/CodeGen/VirtRegMap.cpp =================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp @@ -176,6 +176,10 @@ void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnMachineFunction(MachineFunction&) override; + MachineFunctionProperties getSetProperties() const override { + return MachineFunctionProperties().set( + MachineFunctionProperties::Property::AllVRegsAllocated); + } }; } // end anonymous namespace @@ -445,4 +449,3 @@ } } } -