This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Allow GatherAllAliases to pass through inline asm calls and glued nodes.
AcceptedPublic

Authored by niravd on Mar 6 2019, 12:16 PM.

Details

Summary

Teach GatherAllAliases to reason about inline assembly nodes and
associated glued CopyToReg/CopyFromReg nodes.

This fixes PR9517.

Event Timeline

niravd created this revision.Mar 6 2019, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2019, 12:16 PM
niravd updated this revision to Diff 189556.Mar 6 2019, 12:17 PM

Actual Patch.

Harbormaster completed remote builds in B28846: Diff 189556.
niravd retitled this revision from [DAGCombine] Refactor GatherAllAliases. NFCI. to [DAGCombine] Allow GatherAllAliases to pass through inline asm calls and glued nodes..Mar 6 2019, 12:19 PM
niravd edited the summary of this revision. (Show Details)

This is a refactored and rebased version of D49691 so that it looks reasonable on Phabricator. I've factored out a initial NFC patch (the first snapshot in history) to highlight the actual functional change.

niravd added a comment.EditedMar 13 2019, 7:29 AM

Ping.

Just a reminder to ease review: The first diff in the history is an extracted NFC refactoring and difference between Diffs 1 and 2 highlight the actual change.

efriedma added inline comments.Mar 14 2019, 6:16 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
19527

"If this had a glued output, return C"?

I don't follow why it matters if the output is glued, given there isn't a glue input. If I'm understanding correctly, if the copy isn't glued, in it doesn't modify memory. If the copy is glued, the only way to reach this case should be through a recursive call of ImproveChain. Or are you just trying to be conservative here?

niravd updated this revision to Diff 190862.EditedMar 15 2019, 11:40 AM

Realized explanatory comment and associate fixup had been lost in patch stack. Folding it back in.

niravd marked an inline comment as done.Mar 15 2019, 11:40 AM
efriedma added inline comments.Mar 15 2019, 12:05 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
19546

In terms of the actual checks here, is this sufficient to catch any inline asm that accesses memory? Do you need to check for Extra_HasSideEffects? Do you need to check for "indirect" operands separately? (I think it's possible to write an indirect register operand in IR, although I'm not sure clang ever generates them...)

niravd marked an inline comment as done.Mar 25 2019, 11:59 AM
niravd added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
19546

SelectionDAGBuilder updates the inlineasm's ExtraInfo based on the asm parameter constraints so checking extra info should be should be sufficient.

Also, a check for HasExtraSideEffects is probably needed. I've updated the patch as such.

niravd updated this revision to Diff 192175.Mar 25 2019, 11:59 AM
niravd marked an inline comment as done.

Check HasSideEffects in analysis for inlineasm.

efriedma added inline comments.Mar 25 2019, 12:03 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
19546

With the change to check HasExtraSideEffects, can you remove the Mips test changes?

niravd updated this revision to Diff 192283.Mar 26 2019, 8:43 AM

Revert mips test changes

niravd marked 2 inline comments as done.Mar 26 2019, 8:43 AM
This revision is now accepted and ready to land.Mar 28 2019, 1:01 PM