[PATCH] D65790: [TableGen] FieldInit: improve assertion message

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 01:43:09 PDT 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: RKSimon, craig.topper.
lebedev.ri added a project: LLVM.

When fiddling with sched profiles, especially creating new ones, it's amazingly easy
to end up with malformed .td that crashes tablegen, without explanation of the bug.
This changes the most common assertion i have encountered to dump enough information
to be able to fix the .td

Split of from D63628 <https://reviews.llvm.org/D63628>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65790

Files:
  llvm/include/llvm/TableGen/Record.h


Index: llvm/include/llvm/TableGen/Record.h
===================================================================
--- llvm/include/llvm/TableGen/Record.h
+++ llvm/include/llvm/TableGen/Record.h
@@ -1263,7 +1263,14 @@
 
   FieldInit(Init *R, StringInit *FN)
       : TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
-    assert(getType() && "FieldInit with non-record type!");
+#ifndef NDEBUG
+    if (!getType()) {
+      llvm::errs() << "In Record = " << Rec->getAsString()
+                   << ", got FieldName = " << *FieldName
+                   << " with non-record type!\n";
+      llvm_unreachable("FieldInit with non-record type!");
+    }
+#endif
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65790.213533.patch
Type: text/x-patch
Size: 693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190806/0b274c6e/attachment.bin>


More information about the llvm-commits mailing list