From e49fcfc7cdf82e41f15a857083c0fb275c1b6021 Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Sat, 13 Nov 2021 09:24:05 +0800 Subject: [PATCH] [X86][ABI] Change the alignment of f80 in 32-bit calling convention to meet with different data layout Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D113739 --- llvm/lib/Target/X86/X86CallingConv.td | 4 ++-- llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll | 6 ++++-- llvm/test/CodeGen/X86/inline-asm-fpstack.ll | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td index 63757cc..9bf6213 100644 --- a/llvm/lib/Target/X86/X86CallingConv.td +++ b/llvm/lib/Target/X86/X86CallingConv.td @@ -862,8 +862,8 @@ def CC_X86_32_Common : CallingConv<[ // Doubles get 8-byte slots that are 4-byte aligned. CCIfType<[f64], CCAssignToStack<8, 4>>, - // Long doubles get slots whose size depends on the subtarget. - CCIfType<[f80], CCAssignToStack<0, 4>>, + // Long doubles get slots whose size and alignment depends on the subtarget. + CCIfType<[f80], CCAssignToStack<0, 0>>, // Boolean vectors of AVX-512 are passed in SIMD registers. // The call from AVX to AVX-512 function should work, diff --git a/llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll b/llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll index 3ad6492..2cf09a9 100644 --- a/llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll +++ b/llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll @@ -8,8 +8,9 @@ entry: ret x86_fp80 %tmp2 ; CHECK-LABEL: foo: -; CHECK: fldt 4(%esp) +; CHECK: fldt 16(%esp) ; CHECK-NEXT: fsqrt +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: ret } @@ -20,10 +21,11 @@ entry: %tmp2 = call x86_fp80 @llvm.powi.f80.i32( x86_fp80 %x, i32 3 ) ret x86_fp80 %tmp2 ; CHECK-LABEL: bar: -; CHECK: fldt 4(%esp) +; CHECK: fldt 16(%esp) ; CHECK-NEXT: fld %st(0) ; CHECK-NEXT: fmul %st(1) ; CHECK-NEXT: fmulp +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: ret } diff --git a/llvm/test/CodeGen/X86/inline-asm-fpstack.ll b/llvm/test/CodeGen/X86/inline-asm-fpstack.ll index 09f5114..757f259 100644 --- a/llvm/test/CodeGen/X86/inline-asm-fpstack.ll +++ b/llvm/test/CodeGen/X86/inline-asm-fpstack.ll @@ -29,10 +29,12 @@ define double @test2() nounwind { define void @test3(x86_fp80 %X) nounwind { ; CHECK-LABEL: test3: ; CHECK: ## %bb.0: +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: ## InlineAsm Start ; CHECK-NEXT: frob ; CHECK-NEXT: ## InlineAsm End +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl call void asm sideeffect "frob ", "{st(0)},~{st},~{dirflag},~{fpsr},~{flags}"( x86_fp80 %X) ret void @@ -246,12 +248,14 @@ entry: define void @fist1(x86_fp80 %x, i32* %p) nounwind ssp { ; CHECK-LABEL: fist1: ; CHECK: ## %bb.0: ## %entry +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax ; CHECK-NEXT: ## InlineAsm Start ; CHECK-NEXT: fistl (%eax) ; CHECK-NEXT: ## InlineAsm End ; CHECK-NEXT: fstp %st(0) +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl entry: tail call void asm sideeffect "fistl $1", "{st},*m,~{memory},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %x, i32* %p) nounwind @@ -269,11 +273,13 @@ entry: define x86_fp80 @fist2(x86_fp80 %x, i32* %p) nounwind ssp { ; CHECK-LABEL: fist2: ; CHECK: ## %bb.0: ## %entry +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax ; CHECK-NEXT: ## InlineAsm Start ; CHECK-NEXT: fistl (%eax) ; CHECK-NEXT: ## InlineAsm End +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl entry: %0 = tail call x86_fp80 asm "fistl $2", "=&{st},0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %x, i32* %p) nounwind @@ -288,6 +294,7 @@ entry: define void @fucomp1(x86_fp80 %x, x86_fp80 %y) nounwind ssp { ; CHECK-LABEL: fucomp1: ; CHECK: ## %bb.0: ## %entry +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fxch %st(1) @@ -295,6 +302,7 @@ define void @fucomp1(x86_fp80 %x, x86_fp80 %y) nounwind ssp { ; CHECK-NEXT: fucomp %st(1) ; CHECK-NEXT: ## InlineAsm End ; CHECK-NEXT: fstp %st(0) +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl entry: tail call void asm sideeffect "fucomp $1", "{st},f,~{st},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %x, x86_fp80 %y) nounwind @@ -314,6 +322,7 @@ entry: define void @fucomp2(x86_fp80 %x, x86_fp80 %y) nounwind ssp { ; CHECK-LABEL: fucomp2: ; CHECK: ## %bb.0: ## %entry +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fxch %st(1) @@ -321,6 +330,7 @@ define void @fucomp2(x86_fp80 %x, x86_fp80 %y) nounwind ssp { ; CHECK-NEXT: fucomp %st(1) ; CHECK-NEXT: ## InlineAsm End ; CHECK-NEXT: fstp %st(0) +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl entry: tail call void asm sideeffect "fucomp $1", "{st},{st(1)},~{st},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %x, x86_fp80 %y) nounwind @@ -330,12 +340,14 @@ entry: define void @fucomp3(x86_fp80 %x, x86_fp80 %y) nounwind ssp { ; CHECK-LABEL: fucomp3: ; CHECK: ## %bb.0: ## %entry +; CHECK-NEXT: subl $12, %esp ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fldt {{[0-9]+}}(%esp) ; CHECK-NEXT: fxch %st(1) ; CHECK-NEXT: ## InlineAsm Start ; CHECK-NEXT: fucompp %st(1) ; CHECK-NEXT: ## InlineAsm End +; CHECK-NEXT: addl $12, %esp ; CHECK-NEXT: retl entry: tail call void asm sideeffect "fucompp $1", "{st},{st(1)},~{st},~{st(1)},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %x, x86_fp80 %y) nounwind -- 2.7.4