27 #define DEBUG_TYPE "partially-inline-libcalls"
34 PartiallyInlineLibCalls() :
52 "Partially inline calls to library functions",
false,
false)
54 void PartiallyInlineLibCalls::getAnalysisUsage(
AnalysisUsage &AU)
const {
60 bool PartiallyInlineLibCalls::runOnFunction(
Function &
F) {
64 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
66 &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
81 if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() ||
82 !TLI->
getLibFunc(CalledFunc->getName(), LibFunc))
89 optimizeSQRT(Call, CalledFunc, *CurrBB, BB))
104 bool PartiallyInlineLibCalls::optimizeSQRT(
CallInst *Call,
139 Builder.SetInsertPoint(LibCallBB);
141 Builder.Insert(LibCall);
142 Builder.CreateBr(JoinBB);
149 Builder.SetInsertPoint(&CurrBB);
150 Value *FCmp = Builder.CreateFCmpOEQ(Call, Call);
151 Builder.CreateCondBr(FCmp, JoinBB, LibCallBB);
154 Phi->addIncoming(Call, &CurrBB);
155 Phi->addIncoming(LibCall, LibCallBB);
162 return new PartiallyInlineLibCalls();
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
SplitBlock - Split the specified block at the specified instruction - every thing before SplitPt stay...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
CallInst - This class represents a function call, abstracting a target machine's calling convention...
const Function * getParent() const
Return the enclosing method, or null if none.
iterator begin()
Instruction iterator methods.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
NodeTy * getNextNode()
Get the next node, or 0 for the list tail.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Instruction * clone() const
clone() - Create a copy of 'this' instruction that is identical in all ways except the following: ...
Function does not access memory.
bool isFloatingPointTy() const
isFloatingPointTy - Return true if this is one of the six floating point types
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void addAttribute(unsigned i, Attribute::AttrKind attr)
addAttribute - adds the attribute to the list of attributes.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Type * getType() const
All values are typed, get the type of this value.
Provides information about what library functions are available for the current target.
Function * getCalledFunction() const
getCalledFunction - Return the function called, or null if this is an indirect function invocation...
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
FunctionPass * createPartiallyInlineLibCallsPass()
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
LLVMContext & getContext() const
Get the context in which this basic block lives.
LLVM Value Representation.
void initializePartiallyInlineLibCallsPass(PassRegistry &)