[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

Teresa Johnson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 14:33:11 PDT 2023


tejohnson created this revision.
tejohnson added reviewers: aeubanks, nikic.
Herald added subscribers: khei4, wlei, StephenFan, wenlei, hiraditya.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

SimplifyCFG contains a number of transformations that perform
speculation, and will use profile data if it exists in the IR.
However, the first invocations of SimplifyCFG are before both
instrumented and sample PGO annotation. We found cases where
unprofitable speculation was performed in these early invocations, when
subsequent PGO profile data would have prevented it.

Disable the SpeculateBlocks flag before PGO annotation, in compiles
where PGO is provided.

Additionally, guard another transformation in SimplifyCFG with the
SpeculateBlocks flag as it can also speculate instructions and uses
PGO data if available.

This change resulted in noticeable and significant performance
improvements in multiple large internal codes.

Finally, remove an old test that had a difference with this change
(clang/test/CodeGen/pgo-sample-preparation.c), however, was testing
a pipeline configuration that no longer exists in the same way as when
the test was added. The code change being checked does not seem
indicative of a performance issue as the critical path remains the same,
and I could not find any description of a performance issue with the
original commit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155997

Files:
  clang/test/CodeGen/pgo-sample-preparation.c
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
  llvm/test/Transforms/SimplifyCFG/pipeline-delay-speculation-pgo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155997.543071.patch
Type: text/x-patch
Size: 25111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230721/f3f4e1e9/attachment-0001.bin>


More information about the cfe-commits mailing list