Skip to content

Commit 9f6010d

Browse files
committed
[RISCV][GISel] Emit ADJCALLSTACKDOWN/UP instructions in RISCVCallLowering::lowerCall.
This is needed to mark the stack usage for the call. With this change, I'm now able to succesfully execute spec2006int compiled with -O0. There are still many fallbacks that need to be addressed.
1 parent 63c42b1 commit 9f6010d

21 files changed

+450
-11
lines changed

llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ struct RISCVOutgoingValueAssigner : public CallLowering::OutgoingValueAssigner {
4747
const DataLayout &DL = MF.getDataLayout();
4848
const RISCVSubtarget &Subtarget = MF.getSubtarget<RISCVSubtarget>();
4949

50-
return RISCVAssignFn(DL, Subtarget.getTargetABI(), ValNo, ValVT, LocVT,
51-
LocInfo, Flags, State, Info.IsFixed, IsRet,
52-
Info.Ty, *Subtarget.getTargetLowering(),
53-
/*FirstMaskArgument=*/std::nullopt);
50+
if (RISCVAssignFn(DL, Subtarget.getTargetABI(), ValNo, ValVT, LocVT,
51+
LocInfo, Flags, State, Info.IsFixed, IsRet, Info.Ty,
52+
*Subtarget.getTargetLowering(),
53+
/*FirstMaskArgument=*/std::nullopt))
54+
return true;
55+
56+
StackSize = State.getStackSize();
57+
return false;
5458
}
5559
};
5660

@@ -181,10 +185,14 @@ struct RISCVIncomingValueAssigner : public CallLowering::IncomingValueAssigner {
181185
const DataLayout &DL = MF.getDataLayout();
182186
const RISCVSubtarget &Subtarget = MF.getSubtarget<RISCVSubtarget>();
183187

184-
return RISCVAssignFn(DL, Subtarget.getTargetABI(), ValNo, ValVT, LocVT,
185-
LocInfo, Flags, State, /*IsFixed=*/true, IsRet,
186-
Info.Ty, *Subtarget.getTargetLowering(),
187-
/*FirstMaskArgument=*/std::nullopt);
188+
if (RISCVAssignFn(DL, Subtarget.getTargetABI(), ValNo, ValVT, LocVT,
189+
LocInfo, Flags, State, /*IsFixed=*/true, IsRet, Info.Ty,
190+
*Subtarget.getTargetLowering(),
191+
/*FirstMaskArgument=*/std::nullopt))
192+
return true;
193+
194+
StackSize = State.getStackSize();
195+
return false;
188196
}
189197
};
190198

@@ -436,6 +444,13 @@ bool RISCVCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
436444
return false;
437445
}
438446

447+
if (!Info.OrigRet.Ty->isVoidTy() &&
448+
!isSupportedReturnType(Info.OrigRet.Ty, Subtarget))
449+
return false;
450+
451+
MachineInstrBuilder CallSeqStart =
452+
MIRBuilder.buildInstr(RISCV::ADJCALLSTACKDOWN);
453+
439454
SmallVector<ArgInfo, 32> SplitArgInfos;
440455
SmallVector<ISD::OutputArg, 8> Outs;
441456
for (auto &AInfo : Info.OrigArgs) {
@@ -469,12 +484,14 @@ bool RISCVCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
469484

470485
MIRBuilder.insertInstr(Call);
471486

487+
CallSeqStart.addImm(ArgAssigner.StackSize).addImm(0);
488+
MIRBuilder.buildInstr(RISCV::ADJCALLSTACKUP)
489+
.addImm(ArgAssigner.StackSize)
490+
.addImm(0);
491+
472492
if (Info.OrigRet.Ty->isVoidTy())
473493
return true;
474494

475-
if (!isSupportedReturnType(Info.OrigRet.Ty, Subtarget))
476-
return false;
477-
478495
SmallVector<ArgInfo, 4> SplitRetInfos;
479496
splitToValueTypes(Info.OrigRet, SplitRetInfos, DL, CC);
480497

llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/calling-conv-ilp32-ilp32f-common.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ define i32 @caller_double_in_regs() nounwind {
3535
; ILP32: bb.1 (%ir-block.0):
3636
; ILP32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
3737
; ILP32-NEXT: [[C1:%[0-9]+]]:_(s64) = G_FCONSTANT double 2.000000e+00
38+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
3839
; ILP32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
3940
; ILP32-NEXT: $x10 = COPY [[C]](s32)
4041
; ILP32-NEXT: $x11 = COPY [[UV]](s32)
4142
; ILP32-NEXT: $x12 = COPY [[UV1]](s32)
4243
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_double_in_regs, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit-def $x10
44+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
4345
; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
4446
; ILP32-NEXT: $x10 = COPY [[COPY]](s32)
4547
; ILP32-NEXT: PseudoRET implicit $x10
@@ -48,11 +50,13 @@ define i32 @caller_double_in_regs() nounwind {
4850
; ILP32F: bb.1 (%ir-block.0):
4951
; ILP32F-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
5052
; ILP32F-NEXT: [[C1:%[0-9]+]]:_(s64) = G_FCONSTANT double 2.000000e+00
53+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
5154
; ILP32F-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
5255
; ILP32F-NEXT: $x10 = COPY [[C]](s32)
5356
; ILP32F-NEXT: $x11 = COPY [[UV]](s32)
5457
; ILP32F-NEXT: $x12 = COPY [[UV1]](s32)
5558
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_double_in_regs, csr_ilp32f_lp64f, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit-def $x10
59+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
5660
; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
5761
; ILP32F-NEXT: $x10 = COPY [[COPY]](s32)
5862
; ILP32F-NEXT: PseudoRET implicit $x10
@@ -74,7 +78,9 @@ define double @callee_small_scalar_ret() nounwind {
7478
define i64 @caller_small_scalar_ret() nounwind {
7579
; ILP32-LABEL: name: caller_small_scalar_ret
7680
; ILP32: bb.1 (%ir-block.0):
81+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
7782
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_scalar_ret, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
83+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
7884
; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
7985
; ILP32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
8086
; ILP32-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
@@ -85,7 +91,9 @@ define i64 @caller_small_scalar_ret() nounwind {
8591
;
8692
; ILP32F-LABEL: name: caller_small_scalar_ret
8793
; ILP32F: bb.1 (%ir-block.0):
94+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
8895
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_scalar_ret, csr_ilp32f_lp64f, implicit-def $x1, implicit-def $x10, implicit-def $x11
96+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
8997
; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
9098
; ILP32F-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
9199
; ILP32F-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)

llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/calling-conv-ilp32-ilp32f-ilp32d-common.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ define i32 @caller_i64_in_regs() nounwind {
3939
; ILP32: bb.1 (%ir-block.0):
4040
; ILP32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
4141
; ILP32-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
42+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
4243
; ILP32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
4344
; ILP32-NEXT: $x10 = COPY [[C]](s32)
4445
; ILP32-NEXT: $x11 = COPY [[UV]](s32)
4546
; ILP32-NEXT: $x12 = COPY [[UV1]](s32)
4647
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_i64_in_regs, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit-def $x10
48+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
4749
; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
4850
; ILP32-NEXT: $x10 = COPY [[COPY]](s32)
4951
; ILP32-NEXT: PseudoRET implicit $x10
@@ -52,11 +54,13 @@ define i32 @caller_i64_in_regs() nounwind {
5254
; ILP32F: bb.1 (%ir-block.0):
5355
; ILP32F-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
5456
; ILP32F-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
57+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
5558
; ILP32F-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
5659
; ILP32F-NEXT: $x10 = COPY [[C]](s32)
5760
; ILP32F-NEXT: $x11 = COPY [[UV]](s32)
5861
; ILP32F-NEXT: $x12 = COPY [[UV1]](s32)
5962
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_i64_in_regs, csr_ilp32f_lp64f, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit-def $x10
63+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
6064
; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
6165
; ILP32F-NEXT: $x10 = COPY [[COPY]](s32)
6266
; ILP32F-NEXT: PseudoRET implicit $x10
@@ -65,11 +69,13 @@ define i32 @caller_i64_in_regs() nounwind {
6569
; ILP32D: bb.1 (%ir-block.0):
6670
; ILP32D-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
6771
; ILP32D-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
72+
; ILP32D-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
6873
; ILP32D-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
6974
; ILP32D-NEXT: $x10 = COPY [[C]](s32)
7075
; ILP32D-NEXT: $x11 = COPY [[UV]](s32)
7176
; ILP32D-NEXT: $x12 = COPY [[UV1]](s32)
7277
; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_i64_in_regs, csr_ilp32d_lp64d, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit-def $x10
78+
; ILP32D-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
7379
; ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
7480
; ILP32D-NEXT: $x10 = COPY [[COPY]](s32)
7581
; ILP32D-NEXT: PseudoRET implicit $x10
@@ -136,6 +142,7 @@ define i32 @caller_many_scalars() nounwind {
136142
; ILP32-NEXT: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 6
137143
; ILP32-NEXT: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 7
138144
; ILP32-NEXT: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
145+
; ILP32-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def $x2, implicit $x2
139146
; ILP32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[C]](s8)
140147
; ILP32-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[C1]](s16)
141148
; ILP32-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C3]](s64)
@@ -156,6 +163,7 @@ define i32 @caller_many_scalars() nounwind {
156163
; ILP32-NEXT: $x16 = COPY [[C5]](s32)
157164
; ILP32-NEXT: $x17 = COPY [[UV2]](s32)
158165
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_many_scalars, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit $x14, implicit $x15, implicit $x16, implicit $x17, implicit-def $x10
166+
; ILP32-NEXT: ADJCALLSTACKUP 8, 0, implicit-def $x2, implicit $x2
159167
; ILP32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10
160168
; ILP32-NEXT: $x10 = COPY [[COPY1]](s32)
161169
; ILP32-NEXT: PseudoRET implicit $x10
@@ -170,6 +178,7 @@ define i32 @caller_many_scalars() nounwind {
170178
; ILP32F-NEXT: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 6
171179
; ILP32F-NEXT: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 7
172180
; ILP32F-NEXT: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
181+
; ILP32F-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def $x2, implicit $x2
173182
; ILP32F-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[C]](s8)
174183
; ILP32F-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[C1]](s16)
175184
; ILP32F-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C3]](s64)
@@ -190,6 +199,7 @@ define i32 @caller_many_scalars() nounwind {
190199
; ILP32F-NEXT: $x16 = COPY [[C5]](s32)
191200
; ILP32F-NEXT: $x17 = COPY [[UV2]](s32)
192201
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_many_scalars, csr_ilp32f_lp64f, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit $x14, implicit $x15, implicit $x16, implicit $x17, implicit-def $x10
202+
; ILP32F-NEXT: ADJCALLSTACKUP 8, 0, implicit-def $x2, implicit $x2
193203
; ILP32F-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10
194204
; ILP32F-NEXT: $x10 = COPY [[COPY1]](s32)
195205
; ILP32F-NEXT: PseudoRET implicit $x10
@@ -204,6 +214,7 @@ define i32 @caller_many_scalars() nounwind {
204214
; ILP32D-NEXT: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 6
205215
; ILP32D-NEXT: [[C6:%[0-9]+]]:_(s64) = G_CONSTANT i64 7
206216
; ILP32D-NEXT: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
217+
; ILP32D-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def $x2, implicit $x2
207218
; ILP32D-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[C]](s8)
208219
; ILP32D-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[C1]](s16)
209220
; ILP32D-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C3]](s64)
@@ -224,6 +235,7 @@ define i32 @caller_many_scalars() nounwind {
224235
; ILP32D-NEXT: $x16 = COPY [[C5]](s32)
225236
; ILP32D-NEXT: $x17 = COPY [[UV2]](s32)
226237
; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_many_scalars, csr_ilp32d_lp64d, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit $x14, implicit $x15, implicit $x16, implicit $x17, implicit-def $x10
238+
; ILP32D-NEXT: ADJCALLSTACKUP 8, 0, implicit-def $x2, implicit $x2
227239
; ILP32D-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x10
228240
; ILP32D-NEXT: $x10 = COPY [[COPY1]](s32)
229241
; ILP32D-NEXT: PseudoRET implicit $x10
@@ -248,7 +260,9 @@ define i32 @caller_small_scalar_ret() nounwind {
248260
; ILP32-LABEL: name: caller_small_scalar_ret
249261
; ILP32: bb.1 (%ir-block.0):
250262
; ILP32-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 987654321234567
263+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
251264
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_scalar_ret, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
265+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
252266
; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
253267
; ILP32-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
254268
; ILP32-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
@@ -260,7 +274,9 @@ define i32 @caller_small_scalar_ret() nounwind {
260274
; ILP32F-LABEL: name: caller_small_scalar_ret
261275
; ILP32F: bb.1 (%ir-block.0):
262276
; ILP32F-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 987654321234567
277+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
263278
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_scalar_ret, csr_ilp32f_lp64f, implicit-def $x1, implicit-def $x10, implicit-def $x11
279+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
264280
; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
265281
; ILP32F-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
266282
; ILP32F-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
@@ -272,7 +288,9 @@ define i32 @caller_small_scalar_ret() nounwind {
272288
; ILP32D-LABEL: name: caller_small_scalar_ret
273289
; ILP32D: bb.1 (%ir-block.0):
274290
; ILP32D-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 987654321234567
291+
; ILP32D-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
275292
; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_scalar_ret, csr_ilp32d_lp64d, implicit-def $x1, implicit-def $x10, implicit-def $x11
293+
; ILP32D-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
276294
; ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
277295
; ILP32D-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
278296
; ILP32D-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
@@ -304,7 +322,9 @@ define %struct.small @callee_small_struct_ret() nounwind {
304322
define i32 @caller_small_struct_ret() nounwind {
305323
; ILP32-LABEL: name: caller_small_struct_ret
306324
; ILP32: bb.1 (%ir-block.0):
325+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
307326
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_struct_ret, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
327+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
308328
; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
309329
; ILP32-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
310330
; ILP32-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0)
@@ -314,7 +334,9 @@ define i32 @caller_small_struct_ret() nounwind {
314334
;
315335
; ILP32F-LABEL: name: caller_small_struct_ret
316336
; ILP32F: bb.1 (%ir-block.0):
337+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
317338
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_struct_ret, csr_ilp32f_lp64f, implicit-def $x1, implicit-def $x10, implicit-def $x11
339+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
318340
; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
319341
; ILP32F-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
320342
; ILP32F-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0)
@@ -324,7 +346,9 @@ define i32 @caller_small_struct_ret() nounwind {
324346
;
325347
; ILP32D-LABEL: name: caller_small_struct_ret
326348
; ILP32D: bb.1 (%ir-block.0):
349+
; ILP32D-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
327350
; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_struct_ret, csr_ilp32d_lp64d, implicit-def $x1, implicit-def $x10, implicit-def $x11
351+
; ILP32D-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
328352
; ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
329353
; ILP32D-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x11
330354
; ILP32D-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0)
@@ -378,8 +402,10 @@ define i32 @caller_large_struct_ret() nounwind {
378402
; ILP32-LABEL: name: caller_large_struct_ret
379403
; ILP32: bb.1 (%ir-block.0):
380404
; ILP32-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
405+
; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
381406
; ILP32-NEXT: $x10 = COPY [[FRAME_INDEX]](p0)
382407
; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_large_struct_ret, csr_ilp32_lp64, implicit-def $x1, implicit $x10
408+
; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
383409
; ILP32-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (dereferenceable load (s32) from %ir.1)
384410
; ILP32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
385411
; ILP32-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = nuw G_PTR_ADD [[FRAME_INDEX]], [[C]](s32)
@@ -391,8 +417,10 @@ define i32 @caller_large_struct_ret() nounwind {
391417
; ILP32F-LABEL: name: caller_large_struct_ret
392418
; ILP32F: bb.1 (%ir-block.0):
393419
; ILP32F-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
420+
; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
394421
; ILP32F-NEXT: $x10 = COPY [[FRAME_INDEX]](p0)
395422
; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_large_struct_ret, csr_ilp32f_lp64f, implicit-def $x1, implicit $x10
423+
; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
396424
; ILP32F-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (dereferenceable load (s32) from %ir.1)
397425
; ILP32F-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
398426
; ILP32F-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = nuw G_PTR_ADD [[FRAME_INDEX]], [[C]](s32)
@@ -404,8 +432,10 @@ define i32 @caller_large_struct_ret() nounwind {
404432
; ILP32D-LABEL: name: caller_large_struct_ret
405433
; ILP32D: bb.1 (%ir-block.0):
406434
; ILP32D-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
435+
; ILP32D-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
407436
; ILP32D-NEXT: $x10 = COPY [[FRAME_INDEX]](p0)
408437
; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_large_struct_ret, csr_ilp32d_lp64d, implicit-def $x1, implicit $x10
438+
; ILP32D-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
409439
; ILP32D-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (dereferenceable load (s32) from %ir.1)
410440
; ILP32D-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
411441
; ILP32D-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = nuw G_PTR_ADD [[FRAME_INDEX]], [[C]](s32)

0 commit comments

Comments
 (0)