[PATCH] D90829: [GlobalISel][TableGen] Fix seg fault for zero instruction

Gabriel Hjort Ã…kerlund via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 02:00:20 PST 2020


ehjogab updated this revision to Diff 307000.
ehjogab marked 2 inline comments as done.
ehjogab added a comment.

Missed a part of the CHECK


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90829/new/

https://reviews.llvm.org/D90829

Files:
  llvm/test/TableGen/GlobalISelEmitter-zero-instr.td
  llvm/utils/TableGen/GlobalISelEmitter.cpp


Index: llvm/utils/TableGen/GlobalISelEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -5086,9 +5086,9 @@
 
   if (Dst->isLeaf()) {
     Record *RCDef = getInitValueAsRegClass(Dst->getLeafValue());
-
-    const CodeGenRegisterClass &RC = Target.getRegisterClass(RCDef);
     if (RCDef) {
+      const CodeGenRegisterClass &RC = Target.getRegisterClass(RCDef);
+
       // We need to replace the def and all its uses with the specified
       // operand. However, we must also insert COPY's wherever needed.
       // For now, emit a copy and let the register allocator clean up.
Index: llvm/test/TableGen/GlobalISelEmitter-zero-instr.td
===================================================================
--- /dev/null
+++ llvm/test/TableGen/GlobalISelEmitter-zero-instr.td
@@ -0,0 +1,8 @@
+// RUN: llvm-tblgen -gen-global-isel -optimize-match-table=false -I %p/../../include -I %p/Common %s -o /dev/null --warn-on-skipped-patterns 2>&1 < %s 2>&1 | FileCheck %s
+
+include "llvm/Target/Target.td"
+include "GlobalISelEmitterCommon.td"
+
+// CHECK: warning: Skipped pattern: Dst pattern root isn't a known leaf
+def : Pat<(zext (i16 (trunc i32:$src))),
+          (i32 $src)>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90829.307000.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201123/7765a7cf/attachment.bin>


More information about the llvm-commits mailing list