LLVM 24.0.0git
WholeProgramDevirt.cpp File Reference
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "IPOOptions.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/TypeMetadataUtils.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndexYAML.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GlobPattern.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/Transforms/Utils/Evaluator.h"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <limits>
#include <map>
#include <set>
#include <string>

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< VTableSlot >
struct  llvm::DenseMapInfo< VTableSlotSummary >

Macros

#define DEBUG_TYPE   "wholeprogramdevirt"

Functions

 STATISTIC (NumDevirtTargets, "Number of whole program devirtualization targets")
 STATISTIC (NumSingleImpl, "Number of single implementation devirtualizations")
 STATISTIC (NumBranchFunnel, "Number of branch funnels")
 STATISTIC (NumUniformRetVal, "Number of uniform return value optimizations")
 STATISTIC (NumUniqueRetVal, "Number of unique return value optimizations")
 STATISTIC (NumVirtConstProp1Bit, "Number of 1 bit virtual constant propagations")
 STATISTIC (NumVirtConstProp, "Number of virtual constant propagations")
 DEBUG_COUNTER (CallsToDevirt, "calls-to-devirt", "Controls how many calls should be devirtualized.")
static bool mustBeUnreachableFunction (ValueInfo TheFnVI)
static bool typeIDVisibleToRegularObj (StringRef TypeID, function_ref< bool(StringRef)> IsVisibleToRegularObj)
static bool skipUpdateDueToValidation (GlobalVariable &GV, function_ref< bool(StringRef)> IsVisibleToRegularObj)
static Error checkCombinedSummaryForTesting (const IPOOptions &Opts, ModuleSummaryIndex *Summary)
static bool addCalls (VTableSlotInfo &SlotInfo, const ValueInfo &Callee)
static void findAssumesThroughMergesForTypeTest (SmallVectorImpl< CallInst * > &Assumes, CallInst &TypeTest, SmallPtrSetImpl< Value * > &VisitedMerges)
 Find assumes whose conditions depend on this type test through phi or select nodes.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "wholeprogramdevirt"

Definition at line 128 of file WholeProgramDevirt.cpp.

Function Documentation

◆ addCalls()

bool addCalls ( VTableSlotInfo & SlotInfo,
const ValueInfo & Callee )
static

Definition at line 1309 of file WholeProgramDevirt.cpp.

References llvm::CalleeInfo::Hot, and P.

◆ checkCombinedSummaryForTesting()

Error checkCombinedSummaryForTesting ( const IPOOptions & Opts,
ModuleSummaryIndex * Summary )
static

◆ DEBUG_COUNTER()

DEBUG_COUNTER ( CallsToDevirt ,
"calls-to-devirt" ,
"Controls how many calls should be devirtualized."  )

References llvm::GlobPattern::create(), and T.

◆ findAssumesThroughMergesForTypeTest()

void findAssumesThroughMergesForTypeTest ( SmallVectorImpl< CallInst * > & Assumes,
CallInst & TypeTest,
SmallPtrSetImpl< Value * > & VisitedMerges )
static

◆ mustBeUnreachableFunction()

bool mustBeUnreachableFunction ( ValueInfo TheFnVI)
static

Definition at line 316 of file WholeProgramDevirt.cpp.

References llvm::dyn_cast(), and llvm::ValueInfo::getSummaryList().

◆ skipUpdateDueToValidation()

bool skipUpdateDueToValidation ( GlobalVariable & GV,
function_ref< bool(StringRef)> IsVisibleToRegularObj )
static

◆ STATISTIC() [1/7]

STATISTIC ( NumBranchFunnel ,
"Number of branch funnels"  )

◆ STATISTIC() [2/7]

STATISTIC ( NumDevirtTargets ,
"Number of whole program devirtualization targets"  )

◆ STATISTIC() [3/7]

STATISTIC ( NumSingleImpl ,
"Number of single implementation devirtualizations"  )

◆ STATISTIC() [4/7]

STATISTIC ( NumUniformRetVal ,
"Number of uniform return value optimizations"  )

◆ STATISTIC() [5/7]

STATISTIC ( NumUniqueRetVal ,
"Number of unique return value optimizations"  )

◆ STATISTIC() [6/7]

STATISTIC ( NumVirtConstProp ,
"Number of virtual constant propagations"  )

◆ STATISTIC() [7/7]

STATISTIC ( NumVirtConstProp1Bit ,
"Number of 1 bit virtual constant propagations"  )

◆ typeIDVisibleToRegularObj()

bool typeIDVisibleToRegularObj ( StringRef TypeID,
function_ref< bool(StringRef)> IsVisibleToRegularObj )
static