[all-commits] [llvm/llvm-project] 687e80: [MBP] Add whole chain to BlockFilterSet instead of...

weiguozhi via All-commits all-commits at lists.llvm.org
Wed Dec 16 15:46:31 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 687e80be7fcf75900c354152d8b21500c3b08850
      https://github.com/llvm/llvm-project/commit/687e80be7fcf75900c354152d8b21500c3b08850
  Author: Guozhi Wei <carrot at google.com>
  Date:   2020-12-16 (Wed, 16 Dec 2020)

  Changed paths:
    M llvm/lib/CodeGen/MachineBlockPlacement.cpp
    A llvm/test/CodeGen/X86/block_set.ll

  Log Message:
  -----------
  [MBP] Add whole chain to BlockFilterSet instead of individual BB

Currently we add individual BB to BlockFilterSet if its frequency satisfies

  LoopFreq / Freq <= LoopToColdBlockRatio

LoopFreq is edge frequency from outside to loop header.
LoopToColdBlockRatio is a command line parameter.

It doesn't make sense since we always layout whole chain, not individual BBs.

It may also cause a tricky problem. Sometimes it is possible that the LoopFreq
of an inner loop is smaller than LoopFreq of outer loop. So a BB can be in
BlockFilterSet of inner loop, but not in BlockFilterSet of outer loop,
like .cold in the test case. So it is added to the chain of inner loop. When
work on the outer loop, .cold is not added to BlockFilterSet, so the edge to
successor .problem is not counted in UnscheduledPredecessors of .problem chain.
But other blocks in the inner loop are added BlockFilterSet, so the whole inner
loop chain can be layout, and markChainSuccessors is called to decrease
UnscheduledPredecessors of following chains. markChainSuccessors calls
markBlockSuccessors for every BB, even it is not in BlockFilterSet, like .cold,
so .problem chain's UnscheduledPredecessors is decreased, but this edge was not
counted on in fillWorkLists, so .problem chain's UnscheduledPredecessors
becomes 0 when it still has an unscheduled predecessor .pred! And it causes
problems in following various successor BB selection algorithms.

Differential Revision: https://reviews.llvm.org/D89088




More information about the All-commits mailing list