[llvm-commits] [llvm] r89581 - in /llvm/trunk: test/TableGen/UnsetBitInit.td utils/TableGen/Record.cpp

Bob Wilson bob.wilson at apple.com
Sat Nov 21 19:58:57 PST 2009


Author: bwilson
Date: Sat Nov 21 21:58:57 2009
New Revision: 89581

URL: http://llvm.org/viewvc/llvm-project?rev=89581&view=rev
Log:
Fix pr5470. Tablegen handles template arguments by temporarily setting their
values, resolving references to them, and then removing the definitions.
If a template argument is set to an undefined value, we need to resolve
references to that argument to an explicit undefined value.  The current code
leaves the reference to the template argument as it is, which causes an
assertion failure later when the definition of the template argument is
removed.

Added:
    llvm/trunk/test/TableGen/UnsetBitInit.td
Modified:
    llvm/trunk/utils/TableGen/Record.cpp

Added: llvm/trunk/test/TableGen/UnsetBitInit.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/UnsetBitInit.td?rev=89581&view=auto

==============================================================================
--- llvm/trunk/test/TableGen/UnsetBitInit.td (added)
+++ llvm/trunk/test/TableGen/UnsetBitInit.td Sat Nov 21 21:58:57 2009
@@ -0,0 +1,10 @@
+// RUN: tblgen %s
+class x {
+  field bits<32> A;
+}
+
+class y<bits<2> B> : x {
+  let A{21-20} = B;
+}
+
+def z : y<{0,?}>;

Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=89581&r1=89580&r2=89581&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Sat Nov 21 21:58:57 2009
@@ -490,8 +490,11 @@
   if (Elt >= getSize())
     return 0;  // Out of range reference.
   Init *E = getElement(Elt);
-  if (!dynamic_cast<UnsetInit*>(E))  // If the element is set
-    return E;                        // Replace the VarListElementInit with it.
+  // If the element is set to some value, or if we are resolving a reference
+  // to a specific variable and that variable is explicitly unset, then
+  // replace the VarListElementInit with it.
+  if (IRV || !dynamic_cast<UnsetInit*>(E))
+    return E;
   return 0;
 }
 
@@ -1116,8 +1119,11 @@
   assert(Bit < BI->getNumBits() && "Bit reference out of range!");
   Init *B = BI->getBit(Bit);
 
-  if (!dynamic_cast<UnsetInit*>(B))  // If the bit is not set...
-    return B;                        // Replace the VarBitInit with it.
+  // If the bit is set to some value, or if we are resolving a reference to a
+  // specific variable and that variable is explicitly unset, then replace the
+  // VarBitInit with it.
+  if (IRV || !dynamic_cast<UnsetInit*>(B))
+    return B;
   return 0;
 }
 
@@ -1138,8 +1144,11 @@
   if (Elt >= LI->getSize())
     return 0;  // Out of range reference.
   Init *E = LI->getElement(Elt);
-  if (!dynamic_cast<UnsetInit*>(E))  // If the element is set
-    return E;                        // Replace the VarListElementInit with it.
+  // If the element is set to some value, or if we are resolving a reference
+  // to a specific variable and that variable is explicitly unset, then
+  // replace the VarListElementInit with it.
+  if (IRV || !dynamic_cast<UnsetInit*>(E))
+    return E;
   return 0;
 }
 
@@ -1246,8 +1255,11 @@
       if (Elt >= LI->getSize()) return 0;
       Init *E = LI->getElement(Elt);
 
-      if (!dynamic_cast<UnsetInit*>(E))  // If the bit is set...
-        return E;                  // Replace the VarListElementInit with it.
+      // If the element is set to some value, or if we are resolving a
+      // reference to a specific variable and that variable is explicitly
+      // unset, then replace the VarListElementInit with it.
+      if (RV || !dynamic_cast<UnsetInit*>(E))
+        return E;
     }
   return 0;
 }





More information about the llvm-commits mailing list