Small patch to make tracking down (self-inflicted) bugs easier when the scheduler barfs. The assert() wasn't really helpful at all. At least this patch tells you which instruction and operand to go look at. (Note: In the end, yes, it was my fault, but this patch actually helped.) Index: lib/CodeGen/SelectionDAG/ScheduleDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (revision 522) +++ lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (working copy) @@ -301,9 +301,20 @@ if (II) { const TargetRegisterClass *RC = getInstrOperandRegClass(MRI, TII, II, IIOpNum); + const TargetRegisterClass *VRC = RegMap->getRegClass(VReg); assert(RC && "Don't have operand info for this instruction!"); - assert(RegMap->getRegClass(VReg) == RC && - "Register class of operand and regclass of use don't agree!"); + if (VRC != RC) { + cerr << "Register class of operand and regclass of use don't agree!\n"; + cerr << "Operand = " << IIOpNum << "\n"; + cerr << "Op->Val = "; Op.Val->dump(0); cerr << "\n"; + cerr << "MI = "; MI->print(cerr); + cerr << "VReg = " << VReg << "\n"; + cerr << "VReg RegClass size = " << VRC->getSize() + << ", align = " << VRC->getAlignment() << "\n"; + cerr << "Expected RegClass size = " << RC->getSize() + << ", align = " << RC->getAlignment() << "\n"; + abort(); + } } } else if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
Scott, You have a "dump" in there so that entire block needs to be debug guarded. Please wrap it in #ifndef NDEBUG ... #endif including the VRC definition .. its only needed in debug builds.
Hmm .. actually, you're replacing the assert .. its fine :)
One would think the author of the build system would have this stuff straight. Unfortunately, I need to recant. NDEBUG is set when assertions are turned off so the code *does* need to be wrapped in: #ifndef NDEBUG ... #endif Sorry for the confusion. Better still, figure out how to handle the VRC != RC case :)
Created attachment 652 [details] Resubmitted patch with Reid's suggestions.
Created attachment 660 [details] Updated (with NDEBUG) patch Addresses Reid's comments regarding non-debug builds (although, wouldn't you want to know if this bug showed up). The compromise is to print info only if NDEBUG isn't set.
I applied your patch. Please make sure not to use tabs though :) http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070212/044578.html -Chris