Skip to content

Commit 05af31d

Browse files
committed
correct Dst location calculation
1 parent ecba68c commit 05af31d

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

llvm/lib/Target/X86/X86ISelLoweringCall.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,6 @@ X86TargetLowering::ByValCopyKind X86TargetLowering::ByValNeedsCopyForTailCall(
20472047
int64_t SrcOffset = MFI.getObjectOffset(SrcFI);
20482048
int64_t DstOffset = MFI.getObjectOffset(DstFI);
20492049

2050-
20512050
// If the source is in the local frame, then the copy to the argument
20522051
// memory is always valid.
20532052
bool FixedSrc = MFI.isFixedObjectIndex(SrcFI);
@@ -2232,9 +2231,10 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
22322231

22332232
// Destination: where this byval should live in the callee’s frame
22342233
// after the tail call.
2235-
int32_t Offset = VA.getLocMemOffset() + FPDiff + RetAddrSize;
2236-
SDValue Dst = DAG.getNode(ISD::ADD, dl, PtrVT, StackPtr,
2237-
DAG.getIntPtrConstant(Offset, dl));
2234+
int32_t Offset = VA.getLocMemOffset() + FPDiff ;
2235+
int Size = VA.getLocVT().getFixedSizeInBits() / 8;
2236+
int FI = MF.getFrameInfo().CreateFixedObject(Size, Offset, true);
2237+
SDValue Dst = DAG.getFrameIndex(FI, PtrVT);
22382238

22392239
ByValCopyKind Copy = ByValNeedsCopyForTailCall(DAG, Src, Dst, Flags);
22402240

llvm/test/CodeGen/X86/musttail-inalloca.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ define dso_local x86_thiscallcc void @methodWithVtorDisp_thunk(ptr %0, ptr inall
1818
; CHECK-LABEL: methodWithVtorDisp_thunk:
1919
; CHECK: # %bb.0:
2020
; CHECK-NEXT: pushl %esi
21+
; CHECK-NEXT: subl $20, %esp
2122
; CHECK-NEXT: movl %ecx, %esi
2223
; CHECK-NEXT: subl -4(%ecx), %esi
2324
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
2425
; CHECK-NEXT: pushl $_methodWithVtorDisp_thunk
2526
; CHECK-NEXT: calll ___cyg_profile_func_exit
2627
; CHECK-NEXT: addl $8, %esp
2728
; CHECK-NEXT: movl %esi, %ecx
29+
; CHECK-NEXT: addl $20, %esp
2830
; CHECK-NEXT: popl %esi
2931
; CHECK-NEXT: jmp _methodWithVtorDisp # TAILCALL
3032
%3 = getelementptr inbounds i8, ptr %0, i32 -4

llvm/test/CodeGen/X86/musttail-struct.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -x86-asm-syntax=intel | FileCheck %s
3-
; ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s
43

54
; Test correct handling of a musttail call with a byval struct argument.
65

@@ -117,11 +116,8 @@ define void @large_caller_new_value(%twenty_bytes* byval(%twenty_bytes) align 4
117116
; CHECK-NEXT: movabs rcx, 12884901890
118117
; CHECK-NEXT: mov qword ptr [rsp - 12], rcx
119118
; CHECK-NEXT: mov dword ptr [rsp - 4], 4
120-
; CHECK-NEXT: mov qword ptr [rsp - 40], rax
121-
; CHECK-NEXT: mov qword ptr [rsp - 32], rcx
122119
; CHECK-NEXT: mov qword ptr [rsp + 8], rax
123120
; CHECK-NEXT: mov qword ptr [rsp + 16], rcx
124-
; CHECK-NEXT: mov dword ptr [rsp - 24], 4
125121
; CHECK-NEXT: mov dword ptr [rsp + 24], 4
126122
; CHECK-NEXT: jmp large_callee@PLT # TAILCALL
127123
entry:

0 commit comments

Comments
 (0)