[llvm] [FastISel] Don't select a CallInst as a BasicBlock in the SelectionDAG fallback if it has bundled ops (PR #162895)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 14:50:04 PST 2025
https://github.com/dpaoliello updated https://github.com/llvm/llvm-project/pull/162895
>From ebffce73356e2b0702a873a70a4fa741e5871707 Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Fri, 10 Oct 2025 10:29:17 -0700
Subject: [PATCH] [FastISel] Don't select a CallInst as a BasicBlock in the
SelectionDAG fallback if it has bundled ops
---
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 8 ++++++++
llvm/test/CodeGen/X86/cfguard-checks.ll | 9 ++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index dd8f18d3b8a6a..eca8b6d7c3abd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1837,6 +1837,14 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
reportFastISelFailure(*MF, *ORE, R, EnableFastISelAbort > 2);
+ // If the call has operand bundles, then it's best if they are handled
+ // together with the call instead of selecting the call as its own
+ // block.
+ if (cast<CallInst>(Inst)->hasOperandBundles()) {
+ NumFastIselFailures += NumFastIselRemaining;
+ break;
+ }
+
if (!Inst->getType()->isVoidTy() && !Inst->getType()->isTokenTy() &&
!Inst->use_empty()) {
Register &R = FuncInfo->ValueMap[Inst];
diff --git a/llvm/test/CodeGen/X86/cfguard-checks.ll b/llvm/test/CodeGen/X86/cfguard-checks.ll
index a727bbbfdcbe3..3a2de718e8a1b 100644
--- a/llvm/test/CodeGen/X86/cfguard-checks.ll
+++ b/llvm/test/CodeGen/X86/cfguard-checks.ll
@@ -1,7 +1,9 @@
; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X86
-; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefixes=X64,X64_MSVC
+; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefixes=X64,X64_MSVC,X64_SELDAG
+; RUN: llc < %s --fast-isel -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefixes=X64,X64_MSVC,X64_FISEL
; RUN: llc < %s -mtriple=i686-w64-windows-gnu | FileCheck %s -check-prefixes=X86,X86_MINGW
-; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s -check-prefixes=X64,X64_MINGW
+; RUN: llc < %s -mtriple=x86_64-w64-windows-gnu | FileCheck %s -check-prefixes=X64,X64_MINGW,X64_SELDAG
+; RUN: llc < %s --fast-isel -mtriple=x86_64-w64-windows-gnu | FileCheck %s -check-prefixes=X64,X64_MINGW,X64_FISEL
; Control Flow Guard is currently only available on Windows
; Test that Control Flow Guard checks are correctly added when required.
@@ -27,7 +29,8 @@ entry:
; X64-LABEL: func_guard_nocf
; X64: leaq target_func(%rip), %rax
; X64-NOT: __guard_dispatch_icall_fptr
- ; X64: callq *%rax
+ ; X64_SELDAG: callq *%rax
+ ; X64_FISEL: callq *32(%rsp)
}
attributes #0 = { "guard_nocf" }
More information about the llvm-commits
mailing list