[MBP] Partial tail duplication into hot predecessors
authorGuozhi Wei <carrot@google.com>
Wed, 12 Feb 2020 23:22:33 +0000 (15:22 -0800)
committerGuozhi Wei <carrot@google.com>
Wed, 12 Feb 2020 23:22:33 +0000 (15:22 -0800)
commit369d086d784e0c8cc7add9823f319e95f95dbd81
tree8b2e71a41705f304c2af3493c03691ee849c8c75
parent67f4e0011d318f446354ac3481e2382cd797e9a0
[MBP] Partial tail duplication into hot predecessors

Current tail duplication embedded in MBP duplicates a BB into all or none of its predecessors without too much cost analysis. So sometimes it is duplicated into cold predecessors, and in other cases it may miss the duplication into hot predecessors.

This patch improves tail duplication in 3 aspects:

  A successor can be duplicated into part of its predecessors.
  A more fine-grained benefit analysis, combined with 1, now a successor is duplicated into hot predecessors only.
  If a successor can't be duplicated into one predecessor, it doesn't impact the duplication into other predecessors.

Differential Revision: https://reviews.llvm.org/D73387
llvm/include/llvm/CodeGen/TailDuplicator.h
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/lib/CodeGen/TailDuplicator.cpp
llvm/test/CodeGen/X86/partial-tail-dup.ll [new file with mode: 0644]