[all-commits] [llvm/llvm-project] b60259: [Transforms] Refactor CreateControlFlowHub

Sameer Sahasrabuddhe via All-commits all-commits at lists.llvm.org
Tue Aug 20 21:05:06 PDT 2024


  Branch: refs/heads/users/ssahasra/control-flow-hub
  Home:   https://github.com/llvm/llvm-project
  Commit: b60259d80ee93bfb2bdf33417bb18c522e27a28c
      https://github.com/llvm/llvm-project/commit/b60259d80ee93bfb2bdf33417bb18c522e27a28c
  Author: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
  Date:   2024-08-21 (Wed, 21 Aug 2024)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
    A llvm/include/llvm/Transforms/Utils/ControlFlowUtils.h
    M llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
    M llvm/lib/Transforms/Utils/CMakeLists.txt
    A llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
    M llvm/lib/Transforms/Utils/FixIrreducible.cpp
    M llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
    M llvm/test/CodeGen/AMDGPU/local-atomicrmw-fadd.ll
    M llvm/test/Transforms/FixIrreducible/basic.ll
    M llvm/test/Transforms/FixIrreducible/bug45623.ll
    M llvm/test/Transforms/FixIrreducible/nested.ll
    M llvm/test/Transforms/FixIrreducible/switch.ll
    M llvm/test/Transforms/FixIrreducible/unreachable.ll

  Log Message:
  -----------
  [Transforms] Refactor CreateControlFlowHub

CreateControlFlowHub is a method that redirects control flow edges from a set of
incoming blocks to a set of outgoing blocks through a new set of "guard" blocks.
This is now refactored into a separate file with one enhancement: The input to
the method is now a set of branches rather than two sets of blocks.

The original implementation reroutes every edge from incoming blocks to outgoing
blocks. But it is possible that for some incoming block InBB, some successor S
might be in the set of outgoing blocks, but that particular edge should not be
rerouted. The new implementation makes this possible by allowing the user to
specify the targets of each branch that need to be rerouted.

This is needed when improving the implementation of FixIrreducible #101386.
Current use in FixIrreducible does not demonstrate this finer control over the
edges being rerouted. But in UnifyLoopExits, when only one successor of an
exiting block is an exit block, this refinement now reroutes only the relevant
control-flow through the edge; the non-exit successor is not rerouted. This
results in fewer branches and PHI nodes in the hub.


  Commit: 01beb62d1cce6e2d5f0724d128e4721a929a53c8
      https://github.com/llvm/llvm-project/commit/01beb62d1cce6e2d5f0724d128e4721a929a53c8
  Author: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
  Date:   2024-08-21 (Wed, 21 Aug 2024)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/ControlFlowUtils.h
    M llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
    M llvm/lib/Transforms/Utils/FixIrreducible.cpp
    M llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
    M llvm/test/CodeGen/AMDGPU/exec-mask-opt-cannot-create-empty-or-backward-segment.ll
    M llvm/test/Transforms/FixIrreducible/basic.ll
    M llvm/test/Transforms/FixIrreducible/bug45623.ll
    M llvm/test/Transforms/FixIrreducible/nested.ll
    M llvm/test/Transforms/FixIrreducible/switch.ll
    M llvm/test/Transforms/FixIrreducible/unreachable.ll
    M llvm/test/Transforms/StructurizeCFG/workarounds/needs-unified-loop-exits.ll
    M llvm/test/Transforms/UnifyLoopExits/integer_guards.ll
    M llvm/test/Transforms/UnifyLoopExits/nested.ll
    M llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll
    M llvm/test/Transforms/UnifyLoopExits/undef-phis.ll

  Log Message:
  -----------
  review comments:

- create Int32Ty once
- use poison instead of undef
- single quotes in lit tests
- the check for loop exit is actually very trivial


Compare: https://github.com/llvm/llvm-project/compare/9b8d7f656801...01beb62d1cce

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list