[llvm] r344134 - [TableGen] fix assert in !cast when used out of definition in a multiclass
Valery Pykhtin via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 10 03:52:58 PDT 2018
Author: vpykhtin
Date: Wed Oct 10 03:52:57 2018
New Revision: 344134
URL: http://llvm.org/viewvc/llvm-project?rev=344134&view=rev
Log:
[TableGen] fix assert in !cast when used out of definition in a multiclass
Differential Revision: https://reviews.llvm.org/D53068
Added:
llvm/trunk/test/TableGen/cast-multiclass.td
Modified:
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=344134&r1=344133&r2=344134&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Wed Oct 10 03:52:57 2018
@@ -709,6 +709,8 @@ Init *UnOpInit::Fold(Record *CurRec, boo
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;
Added: llvm/trunk/test/TableGen/cast-multiclass.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/cast-multiclass.td?rev=344134&view=auto
==============================================================================
--- llvm/trunk/test/TableGen/cast-multiclass.td (added)
+++ llvm/trunk/test/TableGen/cast-multiclass.td Wed Oct 10 03:52:57 2018
@@ -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">;
More information about the llvm-commits
mailing list