[llvm] [X86][GlobalISel] Explicitly legalize G_INVOKE_REGION_START (PR #203503)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 04:01:09 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Evgenii Kudriashov (e-kud)
<details>
<summary>Changes</summary>
Removing dependency on the legacy ruleset similarly to #<!-- -->197374
The missing testing coverage was found during LegacyLegalizerInfo removal in #<!-- -->197308
---
Full diff: https://github.com/llvm/llvm-project/pull/203503.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp (+1)
- (added) llvm/test/CodeGen/X86/isel-invoke.ll (+106)
``````````diff
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index 750bb03df21c7..09c2c6ab5f0af 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -623,6 +623,7 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
getActionDefinitionsBuilder({G_INTRINSIC, G_INTRINSIC_W_SIDE_EFFECTS})
.alwaysLegal();
getActionDefinitionsBuilder({G_TRAP, G_DEBUGTRAP, G_UBSANTRAP}).alwaysLegal();
+ getActionDefinitionsBuilder(G_INVOKE_REGION_START).alwaysLegal();
getLegacyLegalizerInfo().computeTables();
verify(*STI.getInstrInfo());
diff --git a/llvm/test/CodeGen/X86/isel-invoke.ll b/llvm/test/CodeGen/X86/isel-invoke.ll
new file mode 100644
index 0000000000000..4484efa45cd1f
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-invoke.ll
@@ -0,0 +1,106 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; NOTE: FastISel can't select and fallbacks to SDAG
+; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86,SDAG-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X86,FASTISEL-X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64,SDAG-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X64,FASTISEL-X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64
+
+declare void @_Unwind_Resume(ptr)
+declare i32 @__gxx_personality_v0(...)
+declare void @bar()
+define void @foo() personality ptr @__gxx_personality_v0 {
+; X86-LABEL: foo:
+; X86: # %bb.0: # %entry
+; X86-NEXT: subl $12, %esp
+; X86-NEXT: .cfi_def_cfa_offset 16
+; X86-NEXT: .Ltmp0: # EH_LABEL
+; X86-NEXT: calll bar at PLT
+; X86-NEXT: .Ltmp1: # EH_LABEL
+; X86-NEXT: # %bb.1: # %invoke.cont
+; X86-NEXT: addl $12, %esp
+; X86-NEXT: .cfi_def_cfa_offset 4
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_2: # %lpad
+; X86-NEXT: .cfi_def_cfa_offset 16
+; X86-NEXT: .Ltmp2: # EH_LABEL
+; X86-NEXT: movl $0, (%esp)
+; X86-NEXT: calll _Unwind_Resume at PLT
+;
+; GISEL-X86-LABEL: foo:
+; GISEL-X86: # %bb.0: # %entry
+; GISEL-X86-NEXT: pushl %esi
+; GISEL-X86-NEXT: .cfi_def_cfa_offset 8
+; GISEL-X86-NEXT: subl $8, %esp
+; GISEL-X86-NEXT: .cfi_def_cfa_offset 16
+; GISEL-X86-NEXT: .cfi_offset %esi, -8
+; GISEL-X86-NEXT: movl $0, %esi
+; GISEL-X86-NEXT: .Ltmp0: # EH_LABEL
+; GISEL-X86-NEXT: calll bar
+; GISEL-X86-NEXT: .Ltmp1: # EH_LABEL
+; GISEL-X86-NEXT: # %bb.1: # %invoke.cont
+; GISEL-X86-NEXT: addl $8, %esp
+; GISEL-X86-NEXT: .cfi_def_cfa_offset 8
+; GISEL-X86-NEXT: popl %esi
+; GISEL-X86-NEXT: .cfi_def_cfa_offset 4
+; GISEL-X86-NEXT: retl
+; GISEL-X86-NEXT: .LBB0_2: # %lpad
+; GISEL-X86-NEXT: .cfi_def_cfa_offset 16
+; GISEL-X86-NEXT: .Ltmp2: # EH_LABEL
+; GISEL-X86-NEXT: movl %esi, (%esp)
+; GISEL-X86-NEXT: calll _Unwind_Resume
+;
+; X64-LABEL: foo:
+; X64: # %bb.0: # %entry
+; X64-NEXT: pushq %rax
+; X64-NEXT: .cfi_def_cfa_offset 16
+; X64-NEXT: .Ltmp0: # EH_LABEL
+; X64-NEXT: callq bar at PLT
+; X64-NEXT: .Ltmp1: # EH_LABEL
+; X64-NEXT: # %bb.1: # %invoke.cont
+; X64-NEXT: popq %rax
+; X64-NEXT: .cfi_def_cfa_offset 8
+; X64-NEXT: retq
+; X64-NEXT: .LBB0_2: # %lpad
+; X64-NEXT: .cfi_def_cfa_offset 16
+; X64-NEXT: .Ltmp2: # EH_LABEL
+; X64-NEXT: xorl %edi, %edi
+; X64-NEXT: callq _Unwind_Resume at PLT
+;
+; GISEL-X64-LABEL: foo:
+; GISEL-X64: # %bb.0: # %entry
+; GISEL-X64-NEXT: pushq %rax
+; GISEL-X64-NEXT: .cfi_def_cfa_offset 16
+; GISEL-X64-NEXT: .Ltmp0: # EH_LABEL
+; GISEL-X64-NEXT: callq bar
+; GISEL-X64-NEXT: .Ltmp1: # EH_LABEL
+; GISEL-X64-NEXT: # %bb.1: # %invoke.cont
+; GISEL-X64-NEXT: popq %rax
+; GISEL-X64-NEXT: .cfi_def_cfa_offset 8
+; GISEL-X64-NEXT: retq
+; GISEL-X64-NEXT: .LBB0_2: # %lpad
+; GISEL-X64-NEXT: .cfi_def_cfa_offset 16
+; GISEL-X64-NEXT: .Ltmp2: # EH_LABEL
+; GISEL-X64-NEXT: movl $0, %edi
+; GISEL-X64-NEXT: callq _Unwind_Resume
+entry:
+ invoke void @bar() to label %invoke.cont unwind label %lpad
+
+invoke.cont: ; preds = %entry
+ ret void
+
+lpad: ; preds = %entry
+ %4 = landingpad { ptr, i32 }
+ cleanup
+ br label %eh.resume
+
+eh.resume: ; preds = %lpad
+ call void @_Unwind_Resume(ptr null) #13
+ unreachable
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; FASTISEL-X64: {{.*}}
+; FASTISEL-X86: {{.*}}
+; SDAG-X64: {{.*}}
+; SDAG-X86: {{.*}}
``````````
</details>
https://github.com/llvm/llvm-project/pull/203503
More information about the llvm-commits
mailing list