[all-commits] [llvm/llvm-project] 2c5a0d: [clang][CFG] Change child order in Reverse Post Or...

Yitzhak Mandelbaum via All-commits all-commits at lists.llvm.org
Tue Jan 30 13:09:28 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2c5a0d392592982bb9c73cbc10c64390b9045873
      https://github.com/llvm/llvm-project/commit/2c5a0d392592982bb9c73cbc10c64390b9045873
  Author: Yitzhak Mandelbaum <ymand at users.noreply.github.com>
  Date:   2024-01-30 (Tue, 30 Jan 2024)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
    M clang/unittests/Analysis/CFGTest.cpp
    M clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp

  Log Message:
  -----------
  [clang][CFG] Change child order in Reverse Post Order (RPO) iteration. (#80030)

The CFG orders the blocks of loop bodies before those of loop successors
(both numerically, and in the successor order of the loop condition
block). So, RPO necessarily reverses that order, placing the loop
successor *before* the loop body. For many analyses, particularly those
that converge to a fixpoint, this results in potentially significant
extra work, because loop successors will necessarily need to be
reconsidered once the algorithm has reached a fixpoint on the loop body.

This definition of CFG graph traits reverses the order of children, so
that loop bodies will come first in an RPO. Then, the algorithm can
fully evaluate the loop and only then consider successor blocks.




More information about the All-commits mailing list