Skip to content

Commit 82f4ebf

Browse files
authored
[RISCV][GISel] Fallback in LowerCall for byval arguments. (#119251)
Our byval call lowering isn't copying the argument. Looks like our SelectionDAG code for byval is different than AArch64 so this may be non-trivial to fix. Reject for now.
1 parent adfe54f commit 82f4ebf

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ bool RISCVCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
596596
for (auto &AInfo : Info.OrigArgs) {
597597
if (!isSupportedArgumentType(AInfo.Ty, Subtarget))
598598
return false;
599+
if (AInfo.Flags[0].isByVal())
600+
return false;
599601
}
600602

601603
if (!Info.OrigRet.Ty->isVoidTy() &&

llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/calls.ll

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -350,31 +350,6 @@ entry:
350350
%struct.Foo = type { i32, i32, i32, i16, i8 }
351351
@foo = global %struct.Foo { i32 1, i32 2, i32 3, i16 4, i8 5 }, align 4
352352

353-
declare void @void_byval_args(ptr byval(%struct.Foo) %f)
354-
355-
define void @test_void_byval_args() {
356-
; RV32I-LABEL: name: test_void_byval_args
357-
; RV32I: bb.1.entry:
358-
; RV32I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
359-
; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
360-
; RV32I-NEXT: $x10 = COPY [[GV]](p0)
361-
; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_byval_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
362-
; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
363-
; RV32I-NEXT: PseudoRET
364-
;
365-
; RV64I-LABEL: name: test_void_byval_args
366-
; RV64I: bb.1.entry:
367-
; RV64I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
368-
; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
369-
; RV64I-NEXT: $x10 = COPY [[GV]](p0)
370-
; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_byval_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
371-
; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
372-
; RV64I-NEXT: PseudoRET
373-
entry:
374-
call void @void_byval_args(ptr byval(%struct.Foo) @foo)
375-
ret void
376-
}
377-
378353
declare void @void_sret_args(ptr sret(%struct.Foo) %f)
379354

380355
define void @test_void_sret_args() {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc -mtriple=riscv32 -verify-machineinstrs -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - 2>&1 | FileCheck %s -check-prefixes=CHECK
2+
; RUN: llc -mtriple=riscv64 -verify-machineinstrs -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - 2>&1 | FileCheck %s -check-prefixes=CHECK
3+
4+
; This file checks that we use the fallback path for things that are known to
5+
; be unsupported on the RISC-V target. It should progressively shrink in size.
6+
7+
%byval.class = type { i32 }
8+
9+
declare void @test_byval_arg(ptr byval(%byval.class) %x)
10+
11+
define void @test_byval_param(ptr %x) {
12+
; CHECK: remark: {{.*}} unable to translate instruction: call
13+
; CHECK-LABEL: warning: Instruction selection used fallback path for test_byval_param
14+
call void @test_byval_arg(ptr byval(%byval.class) %x)
15+
ret void
16+
}

0 commit comments

Comments
 (0)