[PATCH] D53068: TableGen: fix assert in !cast when used out of definition in a multiclass

Valery Pykhtin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 03:54:57 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL344134: [TableGen] fix assert in !cast when used out of definition in a multiclass (authored by vpykhtin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53068?vs=168960&id=168975#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53068

Files:
  llvm/trunk/lib/TableGen/Record.cpp
  llvm/trunk/test/TableGen/cast-multiclass.td


Index: llvm/trunk/lib/TableGen/Record.cpp
===================================================================
--- llvm/trunk/lib/TableGen/Record.cpp
+++ llvm/trunk/lib/TableGen/Record.cpp
@@ -709,6 +709,8 @@
         return StringInit::get(LHSi->getAsString());
     } else if (isa<RecordRecTy>(getType())) {
       if (StringInit *Name = dyn_cast<StringInit>(LHS)) {
+        if (!CurRec && !IsFinal)
+          break;
         assert(CurRec && "NULL pointer");
         Record *D;
 
Index: llvm/trunk/test/TableGen/cast-multiclass.td
===================================================================
--- llvm/trunk/test/TableGen/cast-multiclass.td
+++ llvm/trunk/test/TableGen/cast-multiclass.td
@@ -0,0 +1,23 @@
+// RUN: llvm-tblgen %s | FileCheck %s
+
+class AClass<bit C> {
+  bit Cond = C;
+}
+
+def A0: AClass<0>;
+def A1: AClass<1>;
+
+class BoolToList<bit Value> {
+  list<int> ret = !if(Value, [1]<int>, []<int>);
+}
+
+multiclass P<string AStr> {
+  foreach i = BoolToList<!cast<AClass>(AStr).Cond>.ret in
+    def SubDef;
+}
+
+// CHECK-NOT: def XSubDef
+defm X : P<"A0">;
+
+// CHECK: def YSubDef
+defm Y : P<"A1">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53068.168975.patch
Type: text/x-patch
Size: 1131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181010/cbb8a634/attachment.bin>


More information about the llvm-commits mailing list