[llvm] 889c2b9 - [X86] Fix X32 indirect call generation
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 09:43:53 PDT 2021
Author: Harald van Dijk
Date: 2021-11-03T16:43:44Z
New Revision: 889c2b97bd8c24fec231d239e85eeca7fcee3dd9
URL: https://github.com/llvm/llvm-project/commit/889c2b97bd8c24fec231d239e85eeca7fcee3dd9
DIFF: https://github.com/llvm/llvm-project/commit/889c2b97bd8c24fec231d239e85eeca7fcee3dd9.diff
LOG: [X86] Fix X32 indirect call generation
The check for whether a zero extension was needed was subtly wrong and
saw a value that was already 64 bits, so did not extend.
Fixes PR52357.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D112860
Added:
llvm/test/CodeGen/X86/call-structfp.ll
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 0627e6cb6105..f54a2ae2b4e3 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -4537,7 +4537,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// 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);
}
diff --git a/llvm/test/CodeGen/X86/call-structfp.ll b/llvm/test/CodeGen/X86/call-structfp.ll
new file mode 100644
index 000000000000..7e6c2bbc2a07
--- /dev/null
+++ b/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 ()* } @f()
+define void @pr52357() {
+; CHECK-LABEL: pr52357:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: pushq %rax
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: callq f 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 ()* } @f()
+ %1 = extractvalue { i64, void ()* } %0, 1
+ tail call void %1()
+ ret void
+}
More information about the llvm-commits
mailing list