LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1184 - ScheduleDAG.cpp patch: error message more meaningful.
Summary: ScheduleDAG.cpp patch: error message more meaningful.
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: trunk
Hardware: All Linux
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-06 19:24 PST by Scott Michel
Modified: 2010-02-22 12:41 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
Resubmitted patch with Reid's suggestions. (1.30 KB, patch)
2007-02-07 14:21 PST, Scott Michel
Details
Updated (with NDEBUG) patch (1.30 KB, patch)
2007-02-13 12:31 PST, Scott Michel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Michel 2007-02-06 19:24:39 PST
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)) {
Comment 1 Reid Spencer 2007-02-06 19:30:20 PST
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.
Comment 2 Reid Spencer 2007-02-06 19:30:48 PST
Hmm .. actually, you're replacing the assert .. its fine :)
Comment 3 Reid Spencer 2007-02-06 20:32:57 PST
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 :)
Comment 4 Scott Michel 2007-02-07 14:21:27 PST
Created attachment 652 [details]
Resubmitted patch with Reid's suggestions.
Comment 5 Scott Michel 2007-02-13 12:31:04 PST
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.
Comment 6 Chris Lattner 2007-02-15 12:18:55 PST
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