[PATCH] D90566: [LazyCallGraph] Build SCCs of the reference graph in order

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 1 10:48:37 PST 2020


MaskRay created this revision.
MaskRay added reviewers: aeubanks, asbirlea, jdoerfert, ychen.
Herald added subscribers: llvm-commits, okura, kuter, mgrang, hiraditya.
Herald added a project: LLVM.
MaskRay requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added subscribers: bbn, sstefan1.
Herald added a reviewer: baziotis.

  // The legacy PM CGPassManager discovers SCCs this way:
  for function in the source order
    tarjanSCC(function)
  
  // While the new PM CGSCCPassManager does:
  for function in the reversed source order [1]
    discover a reference graph SCC
    build call graph SCCs inside the reference graph SCC

In the common cases, reference graph ~= call graph, the new PM order is
undesired because for `a | b | c` (3 independent functions), the new PM will
process them in the reversed order: c, b, a. If `a <-> b <-> c`, we can see
that `-print-after-all` will report the sole SCC as `scc: (c, b, a)`.

This patch corrects the iteration order. The discovered SCC order will match
the legacy PM in the common cases.

For some tests (`Transforms/Inline/cgscc-*.ll` and
`unittests/Analysis/CGSCCPassManagerTest.cpp`), the behaviors are dependent on
the SCC discovery order and there are too many check lines for the particular
order.  This patch simply reverses the function order to avoid change too many
check lines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90566

Files:
  llvm/lib/Analysis/LazyCallGraph.cpp
  llvm/test/Analysis/LazyCallGraph/alias.ll
  llvm/test/Analysis/LazyCallGraph/basic.ll
  llvm/test/Other/scc-pass-printer.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Inline/cgscc-cycle-debug.ll
  llvm/test/Transforms/Inline/cgscc-cycle.ll
  llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
  llvm/test/Transforms/Inline/cgscc-invalidate.ll
  llvm/test/Transforms/OpenMP/globalization_remarks.ll
  llvm/test/Transforms/OpenMP/parallel_region_merging.ll
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/Analysis/LazyCallGraphTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90566.302165.patch
Type: text/x-patch
Size: 29581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201101/55e658aa/attachment.bin>


More information about the llvm-commits mailing list