PGOInstrumentation, GCOVProfiling: Split indirectbr critical edges regardless of...
authorMatthias Braun <matthiasb@fb.com>
Wed, 16 Feb 2022 23:01:37 +0000 (15:01 -0800)
committerMatthias Braun <matze@braunis.de>
Thu, 24 Feb 2022 00:27:37 +0000 (16:27 -0800)
commit6a383369f9b800eac5de2456e49fa70577be8e33
tree1259e6acb4551eb500f7ac45d6b2c60b543c3bf6
parentd7a307320e50a0c83d052b04c766e9cf4d618b37
PGOInstrumentation, GCOVProfiling: Split indirectbr critical edges regardless of PHIs

The `SplitIndirectBrCriticalEdges` function was originally designed for
`CodeGenPrepare` and skipped splitting of edges when the destination
block didn't contain any `PHI` instructions. This only makes sense when
reducing COPYs like `CodeGenPrepare`. In the case of
`PGOInstrumentation` or `GCOVProfiling` it would result in missed
counters and wrong result in functions with computed goto.

Differential Revision: https://reviews.llvm.org/D120096
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
llvm/test/Transforms/GCOVProfiling/split-indirectbr-critical-edges.ll
llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
llvm/test/Transforms/PGOProfile/irreducible.ll
llvm/test/Transforms/PGOProfile/split-indirectbr-critical-edges.ll
llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp