[PGO]Implement metadata combine for 'branch_weights' of direct
authorMingming Liu <mingmingl@google.com>
Fri, 21 Apr 2023 06:44:42 +0000 (23:44 -0700)
committerMingming Liu <mingmingl@google.com>
Thu, 27 Apr 2023 20:04:17 +0000 (13:04 -0700)
commitb3cb950cf3d162459a31a9ab533af0f403f344eb
treee632dc12f402953295b456c0bd954f5e3c6eaae5
parentf478721231bdb71ba8f0f6fb21673b9b7f652add
[PGO]Implement metadata combine for 'branch_weights' of direct
callsites when none of the instructions folds the rest away.

- Merge cases are added for simplify-cfg {sink,hoist}, based on https://gcc.godbolt.org/z/avGvc38W7 and https://gcc.godbolt.org/z/dbWbjGhaE
- When one instruction folds the others in, do not update branch_weights
  with sum (see test/Transforms/GVN/calls-readonly.ll)

Differential Revision: https://reviews.llvm.org/D148877
llvm/include/llvm/IR/Metadata.h
llvm/lib/IR/Metadata.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/GVN/calls-readonly.ll
llvm/test/Transforms/SimplifyCFG/merge-direct-call-branch-weights-in-hoist.ll [new file with mode: 0644]
llvm/test/Transforms/SimplifyCFG/merge-direct-call-branch-weights-in-sink.ll [new file with mode: 0644]