[PATCH] D40658: [PGO] Make indirect call promotion a utility

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 09:50:36 PST 2017


mssimpso created this revision.
Herald added a subscriber: mgorny.

This patch factors out the main code transformation utilities in the pgo-driven indirect call promotion pass and places them in Transforms/Utils. The change is intended to let non-pgo-driven passes share a common implementation with the existing pgo-driven pass.

The common utilities promote indirect call sites to direct call sites, either conditionally or unconditionally. They perform the underlying transformation, and do not consider profile information. The pgo-specific details (e.g., the computation of branch weight metadata) have been left in the indirect call promotion pass.

This patch is mostly non-functional, but there are some minor changes to the transformation, which can be seen in the changes to the existing test cases. These changes are meant to accommodate the planned use case in https://reviews.llvm.org/D39869. First, this patch adds the ability to unconditionally promote a given call site (without creating an if-then-else). This interface can be used if it's known that an indirect call has only one possible callee. Second, this patch changes the interface for conditional call site promotion so that the given call site is modified, and a new indirect call site is created and returned (the call site in the "else" block). Previously, a new direct call site was created and returned (the call site in the "then" block), and the given call site remained unmodified. This matches the interface for unconditional promotion in that the given call site is modified in place. There are also some superficial changes to the existing test cases. For example, some values have different names, and bitcast instructions are avoided when unnecessary.


https://reviews.llvm.org/D40658

Files:
  include/llvm/Transforms/Instrumentation.h
  include/llvm/Transforms/Utils/CallPromotionUtils.h
  lib/Transforms/IPO/SampleProfile.cpp
  lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
  lib/Transforms/Utils/CMakeLists.txt
  lib/Transforms/Utils/CallPromotionUtils.cpp
  test/Transforms/PGOProfile/icp_covariant_call_return.ll
  test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
  test/Transforms/PGOProfile/icp_invoke.ll
  test/Transforms/PGOProfile/icp_invoke_nouse.ll
  test/Transforms/PGOProfile/icp_mismatch_msg.ll
  test/Transforms/PGOProfile/icp_vararg.ll
  test/Transforms/PGOProfile/indirect_call_promotion.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40658.124959.patch
Type: text/x-patch
Size: 46624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/f63d2439/attachment.bin>


More information about the llvm-commits mailing list