1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
llvm-mirror/include/llvm/Analysis/IndirectCallPromotionAnalysis.h
Chandler Carruth ae65e281f3 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00

69 lines
2.6 KiB
C++

//===- IndirectCallPromotionAnalysis.h - Indirect call analysis -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
/// \file
/// Interface to identify indirect call promotion candidates.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
#define LLVM_ANALYSIS_INDIRECTCALLPROMOTIONANALYSIS_H
#include "llvm/ProfileData/InstrProf.h"
namespace llvm {
class Instruction;
// Class for identifying profitable indirect call promotion candidates when
// the indirect-call value profile metadata is available.
class ICallPromotionAnalysis {
private:
// Allocate space to read the profile annotation.
std::unique_ptr<InstrProfValueData[]> ValueDataArray;
// Count is the call count for the direct-call target.
// TotalCount is the total call count for the indirect-call callsite.
// RemainingCount is the TotalCount minus promoted-direct-call count.
// Return true we should promote this indirect-call target.
bool isPromotionProfitable(uint64_t Count, uint64_t TotalCount,
uint64_t RemainingCount);
// Returns the number of profitable candidates to promote for the
// current ValueDataArray and the given \p Inst.
uint32_t getProfitablePromotionCandidates(const Instruction *Inst,
uint32_t NumVals,
uint64_t TotalCount);
// Noncopyable
ICallPromotionAnalysis(const ICallPromotionAnalysis &other) = delete;
ICallPromotionAnalysis &
operator=(const ICallPromotionAnalysis &other) = delete;
public:
ICallPromotionAnalysis();
/// Returns reference to array of InstrProfValueData for the given
/// instruction \p I.
///
/// The \p NumVals, \p TotalCount and \p NumCandidates
/// are set to the number of values in the array, the total profile count
/// of the indirect call \p I, and the number of profitable candidates
/// in the given array (which is sorted in reverse order of profitability).
///
/// The returned array space is owned by this class, and overwritten on
/// subsequent calls.
ArrayRef<InstrProfValueData>
getPromotionCandidatesForInstruction(const Instruction *I, uint32_t &NumVals,
uint64_t &TotalCount,
uint32_t &NumCandidates);
};
} // end namespace llvm
#endif