This is an archive of the discontinued LLVM Phabricator instance.

[SDAGBuilder] Handle multi-part arguments in argument copy elision (PR63430)
ClosedPublic

Authored by nikic on Jun 21 2023, 8:20 AM.

Details

Summary

When eliding an argument copy, we need to update the chain to ensure the argument reads are performed before later writes. However, the code doing this only handled this for the first part of the argument. If the argument had multiple parts, the chains of the later parts were dropped. Make sure we preserve all chains.

Fixes https://github.com/llvm/llvm-project/issues/63430.

Diff Detail

Event Timeline

nikic created this revision.Jun 21 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2023, 8:20 AM
nikic requested review of this revision.Jun 21 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2023, 8:20 AM
arsenm added a subscriber: arsenm.Jun 21 2023, 8:33 AM
arsenm added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
10928

For some reason this is split into two hooks for the register type and the number of registers. Wouldn't you need to account for the split and promoted / demoted case?

nikic added inline comments.Jun 21 2023, 8:43 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
10928

Not sure which case you have in mind here, but this is doing the same as the code below (line 10954).

pengfei added inline comments.Jun 22 2023, 5:54 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
10928

IIUC, we cannot assume all ValueVTs are the same VT. So it doesn't look correct to sum them together.
How about iterate Ins[i] and check for isSplitEnd?

nikic added inline comments.Jun 22 2023, 6:01 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
10928

This doesn't assume that the VTs are the same, it just sums of the parts for all the (potentially different) VTs. We don't care about the types, just how many there are.

pengfei accepted this revision.Jun 22 2023, 6:01 AM

LGTM.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
10928

Thinking twice, it doesn't matter if ValueVTs is the same or not. We can see them as a whole for conservative reason.

This revision is now accepted and ready to land.Jun 22 2023, 6:01 AM