Move "auto-init" instructions to the dominator of their users
authorserge-sans-paille <sguelton@mozilla.com>
Wed, 2 Nov 2022 07:52:29 +0000 (08:52 +0100)
committerserge-sans-paille <sguelton@mozilla.com>
Mon, 3 Apr 2023 13:27:27 +0000 (15:27 +0200)
commitcca01008cc31a891d0ec70aff2201b25d05d8f1b
tree3ab4f143992b619c0f9767b06ca17bf25ded714e
parent1d23d60c8d0406b9163d223d2721c5e4f1932f50
Move "auto-init" instructions to the dominator of their users

As a result of -ftrivial-auto-var-init, clang generates instructions to
set alloca'd memory to a given pattern, right after the allocation site.
In some cases, this (somehow costly) operation could be delayed, leading
to conditional execution in some cases.

This is not an uncommon situation: it happens ~500 times on the cPython
code base, and much more on the LLVM codebase. The benefit greatly
varies on the execution path, but it should not regress on performance.

Differential Revision: https://reviews.llvm.org/D137707
19 files changed:
llvm/include/llvm/Transforms/Utils/MoveAutoInit.h [new file with mode: 0644]
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Utils/CMakeLists.txt
llvm/lib/Transforms/Utils/MoveAutoInit.cpp [new file with mode: 0644]
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Transforms/MoveAutoInit/branch.ll [new file with mode: 0644]
llvm/test/Transforms/MoveAutoInit/clobber.ll [new file with mode: 0644]
llvm/test/Transforms/MoveAutoInit/fence.ll [new file with mode: 0644]
llvm/test/Transforms/MoveAutoInit/loop.ll [new file with mode: 0644]
llvm/test/Transforms/MoveAutoInit/scalar.ll [new file with mode: 0644]