mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
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 be a non-functional change, letting non-pgo-driven passes share a common implementation with the existing pgo-driven pass. The common utilities are used to conditionally promote indirect call sites to direct call sites. 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. Differential Revision: https://reviews.llvm.org/D40658 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319963 91177308-0d34-0410-b5e6-96231b3b80d8
45 lines
1.8 KiB
C++
45 lines
1.8 KiB
C++
//===- CallPromotionUtils.h - Utilities for call promotion ------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares utilities useful for promoting indirect call sites to
|
|
// direct call sites.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
|
|
#define LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
|
|
|
|
#include "llvm/IR/CallSite.h"
|
|
|
|
namespace llvm {
|
|
|
|
/// Return true if the given indirect call site can be made to call \p Callee.
|
|
///
|
|
/// This function ensures that the number and type of the call site's arguments
|
|
/// and return value match those of the given function. If the types do not
|
|
/// match exactly, they must at least be bitcast compatible. If \p FailureReason
|
|
/// is non-null and the indirect call cannot be promoted, the failure reason
|
|
/// will be stored in it.
|
|
bool isLegalToPromote(CallSite CS, Function *Callee,
|
|
const char **FailureReason = nullptr);
|
|
|
|
/// Promote the given indirect call site to conditionally call \p Callee.
|
|
///
|
|
/// This function creates an if-then-else structure at the location of the call
|
|
/// site. The original call site is promoted and moved into the "then" block. A
|
|
/// clone of the indirect call site is placed in the "else" block and returned.
|
|
/// If \p BranchWeights is non-null, it will be used to set !prof metadata on
|
|
/// the new conditional branch.
|
|
Instruction *promoteCallWithIfThenElse(CallSite CS, Function *Callee,
|
|
MDNode *BranchWeights = nullptr);
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
|