LLVM  10.0.0svn
Classes | Namespaces | Macros | Functions | Variables
WholeProgramDevirt.cpp File Reference
#include "llvm/Transforms/IPO/WholeProgramDevirt.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/SmallVector.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/TypeMetadataUtils.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.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/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndexYAML.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/PassSupport.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/Utils/Evaluator.h"
#include <algorithm>
#include <cstddef>
#include <map>
#include <set>
#include <string>
Include dependency graph for WholeProgramDevirt.cpp:

Go to the source code of this file.

Classes

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

Namespaces

 llvm
 This class represents lattice values for constants.
 

Macros

#define DEBUG_TYPE   "wholeprogramdevirt"
 

Functions

 INITIALIZE_PASS_BEGIN (WholeProgramDevirt, "wholeprogramdevirt", "Whole program devirtualization", false, false) INITIALIZE_PASS_END(WholeProgramDevirt
 
void llvm::runWholeProgramDevirtOnIndex (ModuleSummaryIndex &Summary, std::set< GlobalValue::GUID > &ExportedGUIDs, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
 Perform index-based whole program devirtualization on the Summary index. More...
 
void llvm::updateIndexWPDForExports (ModuleSummaryIndex &Summary, function_ref< bool(StringRef, GlobalValue::GUID)> isExported, std::map< ValueInfo, std::vector< VTableSlotSummary >> &LocalWPDTargetsMap)
 Call after cross-module importing to update the recorded single impl devirt target names for any locals that were exported. More...
 
static bool AddCalls (VTableSlotInfo &SlotInfo, const ValueInfo &Callee)
 

Variables

static cl::opt< PassSummaryActionClSummaryAction ("wholeprogramdevirt-summary-action", cl::desc("What to do with the summary when running this pass"), cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"), clEnumValN(PassSummaryAction::Import, "import", "Import typeid resolutions from summary and globals"), clEnumValN(PassSummaryAction::Export, "export", "Export typeid resolutions to summary and globals")), cl::Hidden)
 
static cl::opt< std::string > ClReadSummary ("wholeprogramdevirt-read-summary", cl::desc("Read summary from given YAML file before running pass"), cl::Hidden)
 
static cl::opt< std::string > ClWriteSummary ("wholeprogramdevirt-write-summary", cl::desc("Write summary to given YAML file after running pass"), cl::Hidden)
 
static cl::opt< unsignedClThreshold ("wholeprogramdevirt-branch-funnel-threshold", cl::Hidden, cl::init(10), cl::ZeroOrMore, cl::desc("Maximum number of call targets per " "call site to enable branch funnels"))
 
static cl::opt< boolPrintSummaryDevirt ("wholeprogramdevirt-print-index-based", cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::desc("Print index-based devirtualization messages"))
 
 wholeprogramdevirt
 
Whole program devirtualization
 
Whole program false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "wholeprogramdevirt"

Function Documentation

◆ AddCalls()

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

Definition at line 890 of file WholeProgramDevirt.cpp.

References llvm::Function::addAttribute(), llvm::wholeprogramdevirt::VTableBits::After, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::alignTo(), Arg, llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, B, llvm::wholeprogramdevirt::VTableBits::Before, llvm::tgtok::Bit, llvm::WholeProgramDevirtResolution::ByArg::Bit, llvm::tgtok::Bits, llvm::wholeprogramdevirt::TypeMemberInfo::Bits, llvm::WholeProgramDevirtResolution::BranchFunnel, llvm::WholeProgramDevirtResolution::ByArg::Byte, llvm::wholeprogramdevirt::AccumBitVector::Bytes, C, ClThreshold, llvm::computeFunctionBodyMemoryAccess(), llvm::StringRef::contains(), llvm::GlobalAlias::create(), llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreateLoad(), DEBUG_TYPE, llvm::dyn_cast(), E, llvm::Triple::ELF, llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::GlobalVariable::eraseFromParent(), llvm::errs(), llvm::GlobalValue::ExternalLinkage, F(), llvm::findDevirtualizableCallsForTypeCheckedLoad(), llvm::findDevirtualizableCallsForTypeTest(), llvm::wholeprogramdevirt::findLowestOffset(), llvm::wholeprogramdevirt::VirtualCallTarget::Fn, GEP, llvm::Attribute::get(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::AttributeSet::get(), llvm::AttributeList::get(), llvm::ConstantAsMetadata::get(), llvm::ConstantDataArray::get(), llvm::MDNode::get(), llvm::UndefValue::get(), llvm::GlobalObject::getAlignment(), llvm::ConstantStruct::getAnon(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getArgOperand(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getAttributes(), llvm::Function::getBasicBlockList(), llvm::ConstantExpr::getBitCast(), llvm::IntegerType::getBitWidth(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCaller(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getCallingConv(), llvm::GlobalObject::getComdat(), llvm::Module::getContext(), llvm::Module::getDataLayout(), llvm::Intrinsic::getDeclaration(), llvm::Function::getFnAttribute(), llvm::AttributeList::getFnAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getFunctionType(), llvm::ConstantExpr::getGetElementPtr(), llvm::ModuleSummaryIndex::getGlobalNameForLocal(), llvm::GlobalValue::getGUID(), llvm::GlobalVariable::getInitializer(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getInstruction(), llvm::ConstantExpr::getIntToPtr(), llvm::GlobalValue::getLinkage(), llvm::ModuleSummaryIndex::getModuleHash(), llvm::Intrinsic::getName(), llvm::Value::getName(), llvm::Target::getName(), llvm::Constant::getNullValue(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::getNumArgOperands(), llvm::AttributeList::getNumAttrSets(), llvm::Module::getOrInsertComdat(), llvm::Module::getOrInsertGlobal(), llvm::ModuleSummaryIndex::getOrInsertTypeIdSummary(), llvm::AttributeList::getParamAttributes(), llvm::DataLayout::getProgramAddressSpace(), llvm::ConstantExpr::getPtrToInt(), llvm::AttributeList::getRetAttributes(), llvm::FunctionType::getReturnType(), llvm::GlobalObject::getSection(), llvm::ValueInfo::getSummaryList(), llvm::Module::getTargetTriple(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::PointerType::getUnqual(), llvm::Attribute::getValueAsString(), llvm::ModuleSummaryIndex::getValueInfo(), llvm::GlobalValue::getValueType(), llvm::GlobalValue::getVisibility(), llvm::Type::getVoidTy(), llvm::Module::global_objects(), llvm::wholeprogramdevirt::VTableBits::GV, llvm::Attribute::hasAttribute(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::HiddenVisibility, llvm::CalleeInfo::Hot, I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, if(), llvm::WholeProgramDevirtResolution::ByArg::Info, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), Int32Ty, llvm::GlobalValue::InternalLinkage, Intr, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::isCall(), llvm::GlobalVariable::isConstant(), llvm::OptimizationRemark::isEnabled(), llvm::GlobalValue::isLocalLinkage(), llvm::FunctionType::isVarArg(), llvm::HexagonISD::JT, llvm::MAK_ReadNone, Name, llvm::Attribute::None, llvm::wholeprogramdevirt::TypeMemberInfo::Offset, P, llvm::FunctionType::params(), llvm::ModuleSummaryIndex::partiallySplitLTOUnits(), PrintSummaryDevirt, llvm::GlobalValue::PrivateLinkage, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::WholeProgramDevirtResolution::ResByArg, llvm::wholeprogramdevirt::VirtualCallTarget::RetVal, llvm::wholeprogramdevirt::setAfterReturnValues(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::setAttributes(), llvm::wholeprogramdevirt::setBeforeReturnValues(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, CallBrTy, IterTy >::setCallingConv(), llvm::GlobalValue::setLinkage(), llvm::Value::setName(), llvm::GlobalObject::setSection(), llvm::Comdat::setSelectionKind(), llvm::GlobalValue::setVisibility(), llvm::WholeProgramDevirtResolution::SingleImpl, llvm::WholeProgramDevirtResolution::SingleImplName, Size, llvm::SmallVectorBase::size(), llvm::ArrayRef< T >::size(), llvm::raw_string_ostream::str(), llvm::Constant::stripPointerCasts(), llvm::Value::stripPointerCasts(), std::swap(), T, llvm::CallInst::TCK_MustTail, llvm::WholeProgramDevirtResolution::TheKind, llvm::WholeProgramDevirtResolution::ByArg::TheKind, llvm::ModuleSummaryIndex::typeIdCompatibleVtableMap(), llvm::WholeProgramDevirtResolution::ByArg::UniformRetVal, llvm::WholeProgramDevirtResolution::ByArg::UniqueRetVal, llvm::Value::use_begin(), llvm::Value::use_empty(), llvm::Value::use_end(), llvm::AArch64CC::VC, llvm::WholeProgramDevirtResolution::ByArg::VirtualConstProp, llvm::TypeIdSummary::WPDRes, llvm::Triple::x86, and llvm::Triple::x86_64.

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( WholeProgramDevirt  ,
"wholeprogramdevirt"  ,
"Whole program devirtualization ,
false  ,
false   
)

Variable Documentation

◆ ClReadSummary

cl::opt<std::string> ClReadSummary("wholeprogramdevirt-read-summary", cl::desc("Read summary from given YAML file before running pass"), cl::Hidden)
static

◆ ClSummaryAction

cl::opt<PassSummaryAction> ClSummaryAction("wholeprogramdevirt-summary-action", cl::desc("What to do with the summary when running this pass"), cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"), clEnumValN(PassSummaryAction::Import, "import", "Import typeid resolutions from summary and globals"), clEnumValN(PassSummaryAction::Export, "export", "Export typeid resolutions to summary and globals")), cl::Hidden)
static

◆ ClThreshold

cl::opt<unsigned> ClThreshold("wholeprogramdevirt-branch-funnel-threshold", cl::Hidden, cl::init(10), cl::ZeroOrMore, cl::desc("Maximum number of call targets per " "call site to enable branch funnels"))
static

Referenced by AddCalls().

◆ ClWriteSummary

cl::opt<std::string> ClWriteSummary("wholeprogramdevirt-write-summary", cl::desc("Write summary to given YAML file after running pass"), cl::Hidden)
static

◆ devirtualization

Whole program devirtualization

Definition at line 674 of file WholeProgramDevirt.cpp.

◆ false

Whole program false

Definition at line 674 of file WholeProgramDevirt.cpp.

◆ PrintSummaryDevirt

cl::opt<bool> PrintSummaryDevirt("wholeprogramdevirt-print-index-based", cl::Hidden, cl::init(false), cl::ZeroOrMore, cl::desc("Print index-based devirtualization messages"))
static

Referenced by AddCalls().

◆ wholeprogramdevirt

wholeprogramdevirt

Definition at line 674 of file WholeProgramDevirt.cpp.