LLVM API Documentation
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionTracker.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/CommandLine.h"
#include <algorithm>
Go to the source code of this file.
static void AddAliasScopeMetadata | ( | CallSite | CS, |
ValueToValueMapTy & | VMap, | ||
const DataLayout * | DL, | ||
AliasAnalysis * | AA | ||
) | [static] |
AddAliasScopeMetadata - If the inlined function has noalias arguments, then add new alias scopes for each noalias argument, tag the mapped noalias parameters with noalias metadata specifying the new scope, and tag all non-derived loads, stores and memory intrinsics with the new alias scopes.
Definition at line 397 of file InlineFunction.cpp.
References llvm::ARM_PROC::A, llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::ValueMap< KeyT, ValueT, Config >::begin(), llvm::MDNode::concatenate(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), EnableNoAliasConversion, llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::MDNode::get(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::Function::getContext(), llvm::Instruction::getMetadata(), llvm::AliasAnalysis::getModRefBehavior(), llvm::Value::getName(), llvm::GetUnderlyingObjects(), llvm::Value::hasName(), I, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT >, KeyT, ValueT, KeyInfoT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isIdentifiedFunctionLocal(), LI, llvm::LLVMContext::MD_alias_scope, llvm::LLVMContext::MD_noalias, Name, Objects, llvm::AliasAnalysis::OnlyAccessesArgumentPointees, llvm::AliasAnalysis::OnlyReadsArgumentPointees, llvm::PointerMayBeCapturedBefore(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::DominatorTreeBase< NodeT >::recalculate(), llvm::Instruction::setMetadata(), llvm::SmallVectorTemplateCommon< T >::size(), and llvm::utostr().
Referenced by llvm::InlineFunction().
static void CloneAliasScopeMetadata | ( | CallSite | CS, |
ValueToValueMapTy & | VMap | ||
) | [static] |
CloneAliasScopeMetadata - When inlining a function that contains noalias scope metadata, this metadata needs to be cloned so that the inlined blocks have different "unqiue scopes" at every call site. Were this not done, then aliasing scopes from a function inlined into a caller multiple times could not be differentiated (and this would lead to miscompiles because the non-aliasing property communicated by the metadata could have call-site-specific control dependencies).
Definition at line 283 of file InlineFunction.cpp.
References llvm::SetVector< T, Vector, Set >::begin(), llvm::ValueMap< KeyT, ValueT, Config >::begin(), llvm::Function::begin(), llvm::MDNode::concatenate(), llvm::MDNode::deleteTemporary(), llvm::NVPTXISD::Dummy, llvm::dyn_cast(), llvm::SetVector< T, Vector, Set >::empty(), llvm::SetVector< T, Vector, Set >::end(), llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::Function::end(), llvm::MDNode::get(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::Function::getContext(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Instruction::getMetadata(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::MDNode::getTemporary(), I, llvm::ARM_PROC::IE, llvm::SetVector< T, Vector, Set >::insert(), llvm::Instruction::mayReadOrWriteMemory(), llvm::LLVMContext::MD_alias_scope, llvm::LLVMContext::MD_noalias, llvm::None, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Instruction::setMetadata(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::InlineFunction().
static void fixupLineNumbers | ( | Function * | Fn, |
Function::iterator | FI, | ||
Instruction * | TheCall | ||
) | [static] |
fixupLineNumbers - Update inlined instructions' line numbers to to encode location where these instructions are inlined.
Definition at line 804 of file InlineFunction.cpp.
References llvm::createInlinedVariable(), llvm::Function::end(), llvm::Instruction::getDebugLoc(), llvm::DebugLoc::isUnknown(), and updateInlinedAtInfo().
Referenced by llvm::InlineFunction().
static Value* HandleByValArgument | ( | Value * | Arg, |
Instruction * | TheCall, | ||
const Function * | CalledFunc, | ||
InlineFunctionInfo & | IFI, | ||
unsigned | ByValAlignment | ||
) | [static] |
HandleByValArgument - When inlining a call site that has a byval argument, we have to make the implicit memcpy explicit by adding it.
Definition at line 703 of file InlineFunction.cpp.
References Align(), llvm::InlineFunctionInfo::AT, llvm::Function::begin(), llvm::InlineFunctionInfo::DL, llvm::SequentialType::getElementType(), llvm::Value::getName(), llvm::getOrEnforceKnownAlignment(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::DataLayout::getPrefTypeAlignment(), llvm::Value::getType(), llvm::Function::onlyReadsMemory(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and llvm::InlineFunctionInfo::StaticAllocas.
Referenced by llvm::InlineFunction().
static void HandleByValArgumentInit | ( | Value * | Dst, |
Value * | Src, | ||
Module * | M, | ||
BasicBlock * | InsertBlock, | ||
InlineFunctionInfo & | IFI | ||
) | [static] |
Definition at line 683 of file InlineFunction.cpp.
References llvm::BasicBlock::begin(), llvm::InlineFunctionInfo::DL, llvm::IRBuilderBase::getInt64(), llvm::ConstantExpr::getSizeOf(), llvm::Value::getType(), and llvm::DataLayout::getTypeStoreSize().
Referenced by llvm::InlineFunction().
static void HandleCallsInBlockInlinedThroughInvoke | ( | BasicBlock * | BB, |
InvokeInliningInfo & | Invoke | ||
) | [static] |
HandleCallsInBlockInlinedThroughInvoke - When we inline a basic block into an invoke, we have to turn all of the calls that can throw into invokes. This function analyze BB to see if there are any calls, and if so, it rewrites them to be invokes that jump to InvokeDest and fills in the PHI nodes in that block with the values specified in InvokeDestPHIValues.
Definition at line 180 of file InlineFunction.cpp.
References llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::BasicBlock::begin(), llvm::InvokeInst::Create(), llvm::CallInst::doesNotThrow(), llvm::dyn_cast(), llvm::BasicBlock::end(), llvm::CallInst::getAttributes(), llvm::CallInst::getCalledValue(), llvm::CallInst::getCallingConv(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), I, llvm::iplist< NodeTy, Traits >::pop_back(), llvm::iplist< NodeTy, Traits >::pop_front(), llvm::Value::replaceAllUsesWith(), Split(), and llvm::BasicBlock::splitBasicBlock().
Referenced by HandleInlinedInvoke().
static void HandleInlinedInvoke | ( | InvokeInst * | II, |
BasicBlock * | FirstNewBlock, | ||
ClonedCodeInfo & | InlinedCodeInfo | ||
) | [static] |
HandleInlinedInvoke - If we inlined an invoke site, we need to convert calls in the body of the inlined function into invokes.
II is the invoke instruction being inlined. FirstNewBlock is the first block of the inlined code (the last block is the end of the function), and InlineCodeInfo is information about the code that got inlined.
Definition at line 231 of file InlineFunction.cpp.
References llvm::ClonedCodeInfo::ContainsCalls, llvm::Function::end(), llvm::LandingPadInst::getClause(), llvm::InvokeInst::getLandingPadInst(), llvm::LandingPadInst::getNumClauses(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::InvokeInst::getUnwindDest(), HandleCallsInBlockInlinedThroughInvoke(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LandingPadInst::isCleanup(), and llvm::BasicBlock::removePredecessor().
Referenced by llvm::InlineFunction().
static bool hasLifetimeMarkers | ( | AllocaInst * | AI | ) | [static] |
Definition at line 769 of file InlineFunction.cpp.
References llvm::Type::getContext(), llvm::Type::getInt8PtrTy(), llvm::Type::getPointerAddressSpace(), llvm::AllocaInst::getType(), isUsedByLifetimeMarker(), and llvm::Value::users().
Referenced by llvm::InlineFunction().
static bool isUsedByLifetimeMarker | ( | Value * | V | ) | [static] |
Definition at line 753 of file InlineFunction.cpp.
References llvm::Value::users().
Referenced by hasLifetimeMarkers().
static void UpdateCallGraphAfterInlining | ( | CallSite | CS, |
Function::iterator | FirstNewBlock, | ||
ValueToValueMapTy & | VMap, | ||
InlineFunctionInfo & | IFI | ||
) | [static] |
UpdateCallGraphAfterInlining - Once we have cloned code over from a callee into the caller, update the specified callgraph to reflect the changes we made. Note that it's possible that not all code was copied over, so only some edges of the callgraph may remain.
Definition at line 623 of file InlineFunction.cpp.
References llvm::CallGraphNode::addCalledFunction(), llvm::CallGraphNode::begin(), llvm::InlineFunctionInfo::CG, llvm::dyn_cast(), llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::CallGraphNode::end(), F(), llvm::ValueMap< KeyT, ValueT, Config >::find(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), I, llvm::InlineFunctionInfo::InlinedCalls, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::CallGraphNode::removeCallEdgeFor(), and llvm::ValueMapIterator< DenseMapT, KeyT >::ValueTypeProxy::second.
Referenced by llvm::InlineFunction().
static DebugLoc updateInlinedAtInfo | ( | const DebugLoc & | DL, |
const DebugLoc & | InlinedAtDL, | ||
LLVMContext & | Ctx | ||
) | [static] |
updateInlinedAtInfo - Helper function used by fixupLineNumbers to recursively update InlinedAtEntry of a DebugLoc.
Definition at line 788 of file InlineFunction.cpp.
References llvm::DebugLoc::get(), llvm::DebugLoc::getAsMDNode(), llvm::DebugLoc::getCol(), llvm::DebugLoc::getFromDILocation(), llvm::DebugLoc::getInlinedAt(), llvm::DebugLoc::getLine(), and llvm::DebugLoc::getScope().
Referenced by fixupLineNumbers().
cl::opt<bool> EnableNoAliasConversion("enable-noalias-to-md-conversion", cl::init(true), cl::Hidden, cl::desc("Convert noalias attributes to metadata during inlining.")) [static] |
Referenced by AddAliasScopeMetadata().