This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][CallLowering] Add support for splitting types according to calling conventions
ClosedPublic

Authored by aemerson on Aug 13 2019, 3:39 PM.

Details

Summary

On AArch64, s128 types have to be split into s64 GPRs when passed as arguments. This change adds the generic support in call lowering for dealing with multiple registers, for incoming and outgoing args. Support for splitting for return types not yet implemented.

Diff Detail

Event Timeline

aemerson created this revision.Aug 13 2019, 3:39 PM

I'm somewhat confused by what the responsibilities of handleAssignments are vs. target code. I already have multiple register breakdowns without this patch in AMDGPU

I'm somewhat confused by what the responsibilities of handleAssignments are vs. target code. I already have multiple register breakdowns without this patch in AMDGPU

IIUC calling convention specified register splits should be generic, and it's handled in generic code by SelectionDAG. Whether handleAssignments is the best place for I'm not sure, but I don't think targets should have to deal with this individually. In arm64 I think we already have some target call lowering code that should really be generic.

paquette added inline comments.Aug 21 2019, 9:18 AM
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
198–200

obligatory braces nit

206

I think a high-level explanation of what we're going to do when we have an incoming vs outgoing handler would be useful.

220

Can we have a comment here explaining what's going on?

225–227

I think that this could use a comment too.

232

Why less than 2?

232–235

braces

296

Pull Args[I].Regs.size() into a variable with a meaningful name?

llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv.ll
1

Why are we falling back now?

aemerson marked 2 inline comments as done.Aug 21 2019, 3:51 PM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
232

Because this is a code path that hasn't been implemented or tested yet. That is, if we're dealing with an outgoing arg, and we failed to assign a location (at the beginning of handleAssignments), and the calling convention says it doesn't need to be split (NumParts < 2), then we don't know what else to do.

llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv.ll
1

We're not, I'm just adding this flag to ensure we error if we do fall back at all.

aemerson updated this revision to Diff 216514.Aug 21 2019, 4:10 PM

Address comments.

t.p.northover added inline comments.Aug 22 2019, 6:35 AM
llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
196

It looks like you only use the ability here to change elements, not add/remove them? I think that's a MutableArrayRef use-case.

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
165

It looks like you only modify elements in place? If so, that's MutableArrayRef's thing.

260

Why only setSplit for outgoing args?

301

Assertion?

aemerson marked an inline comment as done.Aug 22 2019, 11:09 AM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
260

No good reason, I'll add it.

aemerson marked an inline comment as done.Aug 22 2019, 11:15 AM
aemerson added inline comments.
llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
196

Right, but there's no conversion for SmallVectors to MutableArrayRef, only SmallVectorImpl.

aemerson updated this revision to Diff 216683.Aug 22 2019, 11:58 AM

Add split flags to incoming args and assertions.

paquette accepted this revision.Sep 3 2019, 2:24 PM

LGTM

This revision is now accepted and ready to land.Sep 3 2019, 2:24 PM
This revision was automatically updated to reflect the committed changes.
carwil added a subscriber: carwil.Sep 6 2019, 8:48 AM
MarkMurrayARM reopened this revision.Sep 9 2019, 9:04 AM
MarkMurrayARM added a subscriber: MarkMurrayARM.
MarkMurrayARM added inline comments.
llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp
289 ↗(On Diff #218537)

After this commit, I'm seeing this assert firing.

test.c:
typedef struct { int128_t m3 } struct2;
typedef struct {
uint128_t m2 } union12;
fn1(int p1, struct2 p2, p3, p4, p5, union12 p6, p7) {}

Compiled with:
clang -cc1 -triple aarch64-arm-none-eabi -emit-obj -O0 -o test.o test.c

This revision is now accepted and ready to land.Sep 9 2019, 9:04 AM
MarkMurrayARM requested changes to this revision.Sep 9 2019, 9:56 AM
This revision now requires changes to proceed.Sep 9 2019, 9:56 AM

Thanks for the report. I’ll investigate this tomorrow.

aemerson accepted this revision.Sep 11 2019, 5:03 PM

I've fixed this in r371693.

This revision is now accepted and ready to land.Sep 11 2019, 5:04 PM
aemerson closed this revision.Sep 11 2019, 5:04 PM