Skip to content

Conversation

@e-kud
Copy link
Contributor

@e-kud e-kud commented Oct 26, 2025

Nest arguments are supported by CC in X86CallingConv.td. Nothing special is required in GlobalISel as we reuse the code.

Nest attribute is mostly generated by fortran frontend.

Nest arguments are supported by CC in X86CallingConv.td. Nothing special
is required in GlobalISel as we reuse the code.

Nest attribute is mostly generated by fortran frontend.
@llvmbot
Copy link
Member

llvmbot commented Oct 26, 2025

@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-x86

Author: Evgenii Kudriashov (e-kud)

Changes

Nest arguments are supported by CC in X86CallingConv.td. Nothing special is required in GlobalISel as we reuse the code.

Nest attribute is mostly generated by fortran frontend.


Full diff: https://github.com/llvm/llvm-project/pull/165173.diff

2 Files Affected:

  • (modified) llvm/lib/Target/X86/GISel/X86CallLowering.cpp (+1-2)
  • (added) llvm/test/CodeGen/X86/isel-arg-attrs.ll (+23)
diff --git a/llvm/lib/Target/X86/GISel/X86CallLowering.cpp b/llvm/lib/Target/X86/GISel/X86CallLowering.cpp
index c0b9339e9bc34..b07ce2b958fa0 100644
--- a/llvm/lib/Target/X86/GISel/X86CallLowering.cpp
+++ b/llvm/lib/Target/X86/GISel/X86CallLowering.cpp
@@ -280,8 +280,7 @@ bool X86CallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
     if (Arg.hasAttribute(Attribute::ByVal) ||
         Arg.hasAttribute(Attribute::InReg) ||
         Arg.hasAttribute(Attribute::SwiftSelf) ||
-        Arg.hasAttribute(Attribute::SwiftError) ||
-        Arg.hasAttribute(Attribute::Nest) || VRegs[Idx].size() > 1)
+        Arg.hasAttribute(Attribute::SwiftError) || VRegs[Idx].size() > 1)
       return false;
 
     if (Arg.hasAttribute(Attribute::StructRet)) {
diff --git a/llvm/test/CodeGen/X86/isel-arg-attrs.ll b/llvm/test/CodeGen/X86/isel-arg-attrs.ll
new file mode 100644
index 0000000000000..3afee76715d6d
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-arg-attrs.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X86
+; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X64
+
+; The src array should be in R10 or ECX register due to nest attribute
+define i32 @nest_arg(ptr nest %src) {
+; X86-LABEL: nest_arg:
+; X86:       # %bb.0:
+; X86-NEXT:    movl 8(%ecx), %eax
+; X86-NEXT:    retl
+;
+; X64-LABEL: nest_arg:
+; X64:       # %bb.0:
+; X64-NEXT:    movl 8(%r10), %eax
+; X64-NEXT:    retq
+  %off = getelementptr [3 x i32], ptr %src, i32 0, i32 2
+  %ret = load i32, ptr %off
+  ret i32 %ret
+}

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - although I don't have much experience with nest / trampoline attributes

@e-kud
Copy link
Contributor Author

e-kud commented Nov 18, 2025

LGTM - although I don't have much experience with nest / trampoline attributes

Unfortunately I'm not very experienced with them as well. I only have the fact that fortran benchmarks compiled with this patch are passing and validated (the patch significantly increases the portion of function selected by GlobalISel)

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 186274 tests passed
  • 4849 tests skipped

@e-kud e-kud merged commit 49d77d8 into llvm:main Nov 18, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants