This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Pass vector argument by stack correctly.
ClosedPublic

Authored by kito-cheng on Mar 13 2023, 7:14 AM.

Details

Summary

We've a argument lowering logic to prevent floating-point value pass
passed with bit-conversion, but that rule should not applied to vector
arguments.


How to pass argument to foo:

tail call void @foo(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0,
                    <vscale x 16 x float> zeroinitializer,
                    <vscale x 16 x float> zeroinitializer,
                    <vscale x 16 x float> zeroinitializer)

foo take 13 arguments, first 8 argument pass in GPR, and next 2 LMUL 8 vector
arguments passed in v8-v23, and now we run out of argument register for GPR and
vector register, so we must pass last LMUL 8 vector argument by stack.

Which means we should reserve vlenb * 8 byte for stack for the last
vector argument.

Diff Detail

Event Timeline

kito-cheng created this revision.Mar 13 2023, 7:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2023, 7:14 AM
kito-cheng requested review of this revision.Mar 13 2023, 7:14 AM
craig.topper added inline comments.Mar 13 2023, 2:10 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
12797–12800

I wonder if this should be LocInfo == CCValAssign::BCvt or LocInfo != CCValAssign::Indirect? Seems like an assumption is being made about the LocInfo here more than the type.

Changes:

  • Check LocInfo rather than check ValVT.
  • Also add an assertion to make sure no vector type got into wrong path.
This revision is now accepted and ready to land.Mar 14 2023, 9:57 AM
asb accepted this revision.Mar 14 2023, 12:42 PM
This revision was landed with ongoing or failed builds.Mar 15 2023, 2:22 AM
This revision was automatically updated to reflect the committed changes.