[llvm] [X86] Fix crash when calling through __ptr32 function pointer (PR #209078)
Muhammed Shiyas N via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 01:36:28 PDT 2026
================
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; Tail call through addrspace(270) (__ptr32 __sptr) function pointer.
+; The callee should be sign-extended from i32 to i64.
+define i32 @tailcall_sptr(ptr addrspace(270) %fptr, i32 %arg) {
+; CHECK-LABEL: tailcall_sptr:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: movslq %edi, %rax
+; CHECK-NEXT: movl %esi, %edi
+; CHECK-NEXT: jmpq *%rax # TAILCALL
+entry:
+ %call = tail call addrspace(270) i32 %fptr(i32 %arg)
+ ret i32 %call
+}
+
+; Tail call through addrspace(271) (__ptr32 __uptr) function pointer.
+; The callee should be zero-extended from i32 to i64.
+define i32 @tailcall_uptr(ptr addrspace(271) %fptr, i32 %arg) {
+; CHECK-LABEL: tailcall_uptr:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: movq %rdi, %rax
+; CHECK-NEXT: movl %esi, %edi
+; CHECK-NEXT: jmpq *%rax # TAILCALL
+entry:
+ %call = tail call addrspace(271) i32 %fptr(i32 %arg)
+ ret i32 %call
+}
+
+; Non-tail call through addrspace(270) (__ptr32 __sptr) function pointer.
+define i32 @call_sptr(ptr addrspace(270) %fptr, i32 %arg) {
+; CHECK-LABEL: call_sptr:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: pushq %rax
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: movslq %edi, %rax
----------------
Shiyas-N wrote:
Thanks, I kept the current behavior unchanged.
https://github.com/llvm/llvm-project/pull/209078
More information about the llvm-commits
mailing list