This is an archive of the discontinued LLVM Phabricator instance.

[X86] Fold load with tail call more aggressively
AcceptedPublic

Authored by mejedi on May 2 2021, 2:11 AM.

Details

Summary

Enable folding for tail calls with multiple arguments.

Fixes bugzilla issue 50042.

Diff Detail

Event Timeline

mejedi created this revision.May 2 2021, 2:11 AM
mejedi requested review of this revision.May 2 2021, 2:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2021, 2:11 AM
mejedi added inline comments.May 2 2021, 2:31 AM
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
1209

This part I'm least happy about. It was copied verbatim from X86InstrCompiler.td (X86tcret_6regs).

TBH, I don't fully understand the implications of moving LOAD close to TC_RETURN. It looks safe. However, if this check is omitted, we can end up moving the LOAD and not folding it. This is causing malformed DAG during scheduling in test/CodeGen/X86/musttail-varargs.ll, can't figure why.

I don't find any problem in the tests. So I think it looks good. But I'm not familiar with call lowering, I'd like others to sign off.

llvm/test/CodeGen/X86/sibcall-4.ll
7

Nit: This change is confusing. Maybe better to check all assemblys, or to use update_llc_test_checks.py to generate it.

lebedev.ri resigned from this revision.Jan 12 2023, 5:21 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 5:21 PM
Herald added a subscriber: StephenFan. · View Herald Transcript

This patch looks nice. Why wasn't it merged?

pengfei accepted this revision.Jul 1 2023, 6:05 PM

LGTM. Let me know if you need help for committing the patch.

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
1209

LOAD folding requires 2 scratch registers in some cases. If the 6 parameter registers are occupied, there's only one scratch register available.

This revision is now accepted and ready to land.Jul 1 2023, 6:05 PM