llvm.org GIT mirror llvm / e1b1de8
Merging r354846: ------------------------------------------------------------------------ r354846 | djg | 2019-02-25 21:20:19 -0800 (Mon, 25 Feb 2019) | 12 lines [WebAssembly] Properly align fp128 arguments in outgoing varargs arguments For outgoing varargs arguments, it's necessary to check the OrigAlign field of the corresponding OutputArg entry to determine argument alignment, rather than just computing an alignment from the argument value type. This is because types like fp128 are split into multiple argument values, with narrower types that don't reflect the ABI alignment of the full fp128. This fixes the printf("printfL: %4.*Lf\n", 2, lval); testcase. Differential Revision: https://reviews.llvm.org/D58656 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@360826 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 months ago
2 changed file(s) with 32 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
668668 if (IsVarArg) {
669669 // Outgoing non-fixed arguments are placed in a buffer. First
670670 // compute their offsets and the total amount of buffer space needed.
671 for (SDValue Arg :
672 make_range(OutVals.begin() + NumFixedArgs, OutVals.end())) {
671 for (unsigned I = NumFixedArgs; I < Outs.size(); ++I) {
672 const ISD::OutputArg &Out = Outs[I];
673 SDValue &Arg = OutVals[I];
673674 EVT VT = Arg.getValueType();
674675 assert(VT != MVT::iPTR && "Legalized args should be concrete");
675676 Type *Ty = VT.getTypeForEVT(*DAG.getContext());
677 unsigned Align = std::max(Out.Flags.getOrigAlign(),
678 Layout.getABITypeAlignment(Ty));
676679 unsigned Offset = CCInfo.AllocateStack(Layout.getTypeAllocSize(Ty),
677 Layout.getABITypeAlignment(Ty));
680 Align);
678681 CCInfo.addLoc(CCValAssign::getMem(ArgLocs.size(), VT.getSimpleVT(),
679682 Offset, VT.getSimpleVT(),
680683 CCValAssign::Full));
162162 ret void
163163 }
164164
165 ; Test that an fp128 argument is properly aligned and allocated
166 ; within a vararg buffer.
167
168 ; CHECK-LABEL: call_fp128_alignment:
169 ; CHECK: global.get $push7=, __stack_pointer
170 ; CHECK-NEXT: i32.const $push8=, 32
171 ; CHECK-NEXT: i32.sub $push12=, $pop7, $pop8
172 ; CHECK-NEXT: local.tee $push11=, $1=, $pop12
173 ; CHECK-NEXT: global.set __stack_pointer@GLOBAL, $pop11
174 ; CHECK-NEXT: i32.const $push0=, 24
175 ; CHECK-NEXT: i32.add $push1=, $1, $pop0
176 ; CHECK-NEXT: i64.const $push2=, -9223372036854775808
177 ; CHECK-NEXT: i64.store 0($pop1), $pop2
178 ; CHECK-NEXT: i32.const $push3=, 16
179 ; CHECK-NEXT: i32.add $push4=, $1, $pop3
180 ; CHECK-NEXT: i64.const $push5=, 1
181 ; CHECK-NEXT: i64.store 0($pop4), $pop5
182 ; CHECK-NEXT: i32.const $push6=, 7
183 ; CHECK-NEXT: i32.store 0($1), $pop6
184 ; CHECK-NEXT: call callee@FUNCTION, $1
185 define void @call_fp128_alignment(i8* %p) {
186 entry:
187 call void (...) @callee(i8 7, fp128 0xL00000000000000018000000000000000)
188 ret void
189 }
190
165191 declare void @llvm.va_start(i8*)
166192 declare void @llvm.va_end(i8*)
167193 declare void @llvm.va_copy(i8*, i8*)