This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Move pseudo probes to the beginning of a block to unblock SelectionDAG combine.
ClosedPublic

Authored by hoy on Apr 6 2021, 6:32 PM.

Details

Summary

Pseudo probes, when scattered in a block, can be chained dependencies of other regular DAG nodes and block DAG combine optimizations. To fix this, scattered probes in a block are grouped and placed at the beginning of the block. This shouldn't affect the profile quality.

Test Plan:

Diff Detail

Event Timeline

hoy created this revision.Apr 6 2021, 6:32 PM
hoy requested review of this revision.Apr 6 2021, 6:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 6:32 PM
hoy updated this revision to Diff 335915.Apr 7 2021, 1:12 PM

Fixing test issue.

wmi added inline comments.Apr 7 2021, 5:10 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
8004–8005

Why pseudo probes need to be put after debug instructions on the top, is it necessary?

hoy added inline comments.Apr 7 2021, 5:35 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
8004–8005

Probes are not necessary to be after debug instructions, but thought it would be nice to keep existing probes that are in the beginning of the block in order.

wmi accepted this revision.Apr 7 2021, 8:32 PM

LGTM.

This revision is now accepted and ready to land.Apr 7 2021, 8:32 PM
wenlei added inline comments.Apr 7 2021, 9:03 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
8001

For dbg values, redundancy removal and placement are separate. Do we want to follow that?

Since removeRedundantPseudoProbes is part of RemoveRedundantDbgInstrs already, how critical is this extra removal?

hoy added inline comments.Apr 7 2021, 10:33 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
8001

Good point. They should be separate for pseudo probes as well, to be consistent with debug instrs.

The removal is not critical. It doesn't block DAG optimizations. Though it would be nice to remove redundancy from time to time for compilation time. This can be done as a separate change to find more promising places for redundancy removal. Removing it for now.

hoy updated this revision to Diff 336003.Apr 7 2021, 10:35 PM

Removing removeRedundantPseudoProbes calls.

wenlei accepted this revision.Apr 7 2021, 10:36 PM

lgtm, thanks.

This revision was landed with ongoing or failed builds.Apr 7 2021, 10:46 PM
This revision was automatically updated to reflect the committed changes.