[llvm] 352a92f - Fix SystemZ TableGen crashing when GlobalISel is enabled (#228227)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 10:53:14 PDT 2026


Author: Dennis Wang
Date: 2026-10-06T19:53:07+02:00
New Revision: 352a92fbca07663d644fb9999ec30746ab2382cc

URL: https://github.com/llvm/llvm-project/commit/352a92fbca07663d644fb9999ec30746ab2382cc
DIFF: https://github.com/llvm/llvm-project/commit/352a92fbca07663d644fb9999ec30746ab2382cc.diff

LOG: Fix SystemZ TableGen crashing when GlobalISel is enabled (#228227)

## Description

When I enable GlobalISel for SystemZ by adding `tablegen(LLVM
SystemZGenGlobalISel.inc -gen-global-isel)` in `SystemZ/CMakeList`, it
crashes with this trace:

```

0.	Program arguments: /Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen -gen-global-isel -I/Users/dennis/Developer/llvm-project/llvm/lib/Target/SystemZ -I/Users/dennis/Developer/llvm-project/build/include -I/Users/dennis/Developer/llvm-project/llvm/include -I /Users/dennis/Developer/llvm-project/llvm/lib/Target /Users/dennis/Developer/llvm-project/llvm/lib/Target/SystemZ/SystemZ.td --write-if-changed -o SystemZGenGlobalISel.inc -d SystemZGenGlobalISel.inc.d
 #0 0x00000001004897ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1002f17ac)
 #1 0x0000000100486ff0 llvm::sys::RunSignalHandlers() (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1002eeff0)
 #2 0x000000010048a0cc SignalHandler(int, __siginfo*, void*) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1002f20cc)
 #3 0x0000000184d8c144 (/usr/lib/system/libsystem_platform.dylib+0x180898144)
 #4 0x00000001003a1158 llvm::gi::CopyConstantAsImmRenderer& llvm::gi::BuildMIAction::addRenderer<llvm::gi::CopyConstantAsImmRenderer, llvm::gi::RuleMatcher&, llvm::StringRef&>(llvm::gi::RuleMatcher&, llvm::StringRef&) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x100209158)
 #5 0x00000001003a1158 llvm::gi::CopyConstantAsImmRenderer& llvm::gi::BuildMIAction::addRenderer<llvm::gi::CopyConstantAsImmRenderer, llvm::gi::RuleMatcher&, llvm::StringRef&>(llvm::gi::RuleMatcher&, llvm::StringRef&) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x100209158)
 #6 0x00000001003a0688 (anonymous namespace)::GlobalISelEmitter::importNodeRenderer(llvm::gi::RuleMatcher&, llvm::gi::BuildMIAction&, llvm::TreePatternNode const&, std::__1::__list_iterator<std::__1::unique_ptr<llvm::gi::MatchAction, std::__1::default_delete<llvm::gi::MatchAction>>, void*>&) const (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x100208688)
 #7 0x000000010039f11c (anonymous namespace)::GlobalISelEmitter::importExplicitUseRenderers(std::__1::__list_iterator<std::__1::unique_ptr<llvm::gi::MatchAction, std::__1::default_delete<llvm::gi::MatchAction>>, void*>, llvm::gi::RuleMatcher&, llvm::gi::BuildMIAction&, llvm::TreePatternNode const&) const (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x10020711c)
 #8 0x0000000100394a6c (anonymous namespace)::GlobalISelEmitter::run(llvm::raw_ostream&) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1001fca6c)
 #9 0x0000000100392f74 llvm::TableGen::Emitter::OptClass<(anonymous namespace)::GlobalISelEmitter>::run(llvm::StringRef, llvm::RecordKeeper const&) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1001faf74)
#10 0x00000001004aea9c llvm::TableGen::Emitter::ApplyCallback(llvm::RecordKeeper const&, llvm::TableGenOutputFiles&, llvm::StringRef) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x100316a9c)
#11 0x000000010048e968 llvm::TableGenMain(char const*, llvm::function_ref<bool (llvm::TableGenOutputFiles&, llvm::RecordKeeper const&)>) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x1002f6968)
#12 0x00000001001f76d4 tblgen_main(int, char**) (/Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen+0x10005f6d4)
#13 0x00000001849abe80
/bin/sh: line 1: 45648 Segmentation fault: 11  /Users/dennis/Developer/llvm-project/build/bin/llvm-tblgen -gen-global-isel -I/Users/dennis/Developer/llvm-project/llvm/lib/Target/SystemZ -I/Users/dennis/Developer/llvm-project/build/include -I/Users/dennis/Developer/llvm-project/llvm/include -I /Users/dennis/Developer/llvm-project/llvm/lib/Target /Users/dennis/Developer/llvm-project/llvm/lib/Target/SystemZ/SystemZ.td --write-if-changed -o SystemZGenGlobalISel.inc -d SystemZGenGlobalISel.inc.d
ninja: build stopped: subcommand failed.
```

Note that it compiles with no issues when it doesn't have the GlobalISel
instruction on the CMakeList setting.

Turns out the pattern is using `imm` when it should be an `timm`,
causing the pattern to break. After applying my changes, I was able to
build the SystemZ compiler and also ran the entire LLVM test suite.

### AI usage
- AI was used to help me decipher the stack trace and find out which
pattern was causing the issue.
- AI was used to help explain the difference between `imm` and `timm`,
amongst other keywords.
- AI was used to tell me what commands to run to build, and test if my
changes worked.

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/SystemZInstrVector.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/SystemZInstrVector.td b/llvm/lib/Target/SystemZ/SystemZInstrVector.td
index c614af8b295c4..5aefa823ab7aa 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrVector.td
+++ b/llvm/lib/Target/SystemZ/SystemZInstrVector.td
@@ -2426,27 +2426,27 @@ let Predicates = [FeatureVector, FeatureNNPAssist] in {
   let Uses = [FPC], mayRaiseFPException = 1 in
     def VCFN : UnaryVRRaFloatGeneric<"vcfn", 0xE65D>;
   def : Pat<(int_s390_vcfn VR128:$x, imm32zx4_timm:$m),
-            (VCFN VR128:$x, 1, imm32zx4:$m)>;
+            (VCFN VR128:$x, 1, imm32zx4_timm:$m)>;
 
   let Uses = [FPC], mayRaiseFPException = 1 in
     def VCLFNL : UnaryVRRaFloatGeneric<"vclfnl", 0xE65E>;
   def : Pat<(int_s390_vclfnls VR128:$x, imm32zx4_timm:$m),
-            (VCLFNL VR128:$x, 2, imm32zx4:$m)>;
+            (VCLFNL VR128:$x, 2, imm32zx4_timm:$m)>;
 
   let Uses = [FPC], mayRaiseFPException = 1 in
     def VCLFNH : UnaryVRRaFloatGeneric<"vclfnh", 0xE656>;
   def : Pat<(int_s390_vclfnhs VR128:$x, imm32zx4_timm:$m),
-            (VCLFNH VR128:$x, 2, imm32zx4:$m)>;
+            (VCLFNH VR128:$x, 2, imm32zx4_timm:$m)>;
 
   let Uses = [FPC], mayRaiseFPException = 1 in
     def VCNF : UnaryVRRaFloatGeneric<"vcnf", 0xE655>;
   def : Pat<(int_s390_vcnf VR128:$x, imm32zx4_timm:$m),
-            (VCNF VR128:$x, imm32zx4:$m, 1)>;
+            (VCNF VR128:$x, imm32zx4_timm:$m, 1)>;
 
   let Uses = [FPC], mayRaiseFPException = 1 in
     def VCRNF : BinaryVRRcFloatGeneric<"vcrnf", 0xE675>;
   def : Pat<(int_s390_vcrnfs VR128:$x, VR128:$y, imm32zx4_timm:$m),
-            (VCRNF VR128:$x, VR128:$y, imm32zx4:$m, 2)>;
+            (VCRNF VR128:$x, VR128:$y, imm32zx4_timm:$m, 2)>;
 }
 
 //===----------------------------------------------------------------------===//


        


More information about the llvm-commits mailing list