This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare] Handle ExtractValueInst in dupRetToEnableTailCallOpts
ClosedPublic

Authored by Carrot on Feb 7 2020, 10:51 AM.

Details

Summary

As the test case shows if there is an ExtractValueInst in the Ret block, function dupRetToEnableTailCallOpts can't duplicate it into the block containing call. So later no tail call is generated in CodeGen.

This patch adds the ExtractValueInst handling code in function dupRetToEnableTailCallOpts and FoldReturnIntoUncondBranch, and later tail call can be generated for this case.

Diff Detail

Event Timeline

Carrot created this revision.Feb 7 2020, 10:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2020, 10:51 AM
arsenm added a subscriber: arsenm.Feb 7 2020, 10:57 AM
arsenm added inline comments.
llvm/lib/CodeGen/CodeGenPrepare.cpp
2111–2113

getIndices() == { 0 }?

llvm/test/CodeGen/X86/tailcall-extract.ll
2

Should also have a run line checking the IR after just codegenprepare

28

Use a named value

arsenm added inline comments.Feb 7 2020, 11:02 AM
llvm/test/CodeGen/X86/tailcall-extract.ll
28

Also should test the case where the extracted value is also bit casted

Carrot updated this revision to Diff 243276.Feb 7 2020, 1:35 PM
Carrot marked 4 inline comments as done.
Carrot added a reviewer: arsenm.
Carrot added inline comments.
llvm/lib/CodeGen/CodeGenPrepare.cpp
2111–2113

The structure may be nested, so the index array size can be larger than 1.

arsenm added inline comments.Feb 13 2020, 2:52 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
2111–2113

Can you add a test with this case? ssd::all would also be shorter

Carrot updated this revision to Diff 245242.Feb 18 2020, 1:09 PM
Carrot marked an inline comment as done.
arsenm added inline comments.Feb 21 2020, 2:23 PM
llvm/test/CodeGen/X86/tailcall-extract.ll
46

Should stress both the single index case like before, as well as the multi index. Also needs negative tests with non-0 indexes

Carrot updated this revision to Diff 246297.Feb 24 2020, 1:55 PM
Carrot marked an inline comment as done.
arsenm accepted this revision.Mar 2 2020, 12:04 PM

LGTM

llvm/test/CodeGen/X86/tailcall-extract.ll
131

Comments explaining each testcase wouldn't hurt, and/or more descriptive function names

This revision is now accepted and ready to land.Mar 2 2020, 12:04 PM
Carrot updated this revision to Diff 248040.Mar 3 2020, 2:36 PM
Carrot marked an inline comment as done.

Thanks, will commit this version.

This revision was automatically updated to reflect the committed changes.