[PATCH] D112860: [X86] Fix X32 indirect call generation

Harald van Dijk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 18:04:12 PDT 2021


hvdijk updated this revision to Diff 383544.
hvdijk added a comment.

Hm, I should have taken tail call out of the description and test name, this is not limited to tail calls. Then, removing -tailcallopt from the test, it does happen to use a tail call, but that's not the point of the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112860/new/

https://reviews.llvm.org/D112860

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/call-structfp.ll


Index: llvm/test/CodeGen/X86/call-structfp.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/call-structfp.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnux32 | FileCheck %s
+declare { i64, void ()* } @a()
+define void @b() {
+; CHECK-LABEL: b:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    .cfi_def_cfa_offset 16
+; CHECK-NEXT:    callq a at PLT
+; CHECK-NEXT:    movl %edx, %eax
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    .cfi_def_cfa_offset 8
+; CHECK-NEXT:    jmpq *%rax # TAILCALL
+entry:
+  %0 = tail call { i64, void ()* } @a()
+  %1 = extractvalue { i64, void ()* } %0, 1
+  tail call void %1()
+  ret void
+}
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -4531,7 +4531,7 @@
     // address into a register.
     Callee = LowerGlobalOrExternal(Callee, DAG, /*ForCall=*/true);
   } else if (Subtarget.isTarget64BitILP32() &&
-             Callee->getValueType(0) == MVT::i32) {
+             Callee.getValueType() == MVT::i32) {
     // Zero-extend the 32-bit Callee address into a 64-bit according to x32 ABI
     Callee = DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i64, Callee);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112860.383544.patch
Type: text/x-patch
Size: 1446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211030/2ecf9b32/attachment.bin>


More information about the llvm-commits mailing list