[all-commits] [llvm/llvm-project] 297fb6: Use a deterministic order when updating the Domina...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Nov 29 04:22:43 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 297fb66484c73d3a04e8974921e94cb00c1587c2
      https://github.com/llvm/llvm-project/commit/297fb66484c73d3a04e8974921e94cb00c1587c2
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2021-11-29 (Mon, 29 Nov 2021)

  Changed paths:
    M llvm/include/llvm/Support/GenericDomTree.h
    M llvm/lib/CodeGen/IndirectBrExpandPass.cpp
    M llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    A llvm/test/Transforms/JumpThreading/domtree-updates.ll

  Log Message:
  -----------
  Use a deterministic order when updating the DominatorTree

This solves a problem with non-deterministic output from opt due
to not performing dominator tree updates in a deterministic order.

The problem that was analysed indicated that JumpThreading was using
the DomTreeUpdater via llvm::MergeBasicBlockIntoOnlyPred. When
preparing the list of updates to send to DomTreeUpdater::applyUpdates
we iterated over a SmallPtrSet, which didn't give a well-defined
order of updates to perform.

The added domtree-updates.ll test case is an example that would
result in non-deterministic printouts of the domtree. Semantically
those domtree:s are equivalent, but it show the fact that when we
use the domtree iterator the order in which nodes are visited depend
on the order in which dominator tree updates are performed.

Since some passes (at least EarlyCSE) are iterating over nodes in the
dominator tree in a similar fashion as the domtree printer, then the
order in which transforms are applied by such passes, transitively,
also depend on the order in which dominator tree updates are
performed. And taking EarlyCSE as an example the end result could be
different depending on in which order the transforms are applied.

Reviewed By: nikic, kuhar

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




More information about the All-commits mailing list