16 #define DEBUG_TYPE "partially-inline-libcalls"
33 PartiallyInlineLibCalls() :
51 "Partially inline calls to library functions",
false,
false)
53 void PartiallyInlineLibCalls::getAnalysisUsage(
AnalysisUsage &AU)
const {
59 bool PartiallyInlineLibCalls::runOnFunction(
Function &
F) {
78 if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() ||
79 !TLI->
getLibFunc(CalledFunc->getName(), LibFunc))
85 if (TTI->haveFastSqrt(Call->
getType()) &&
86 optimizeSQRT(Call, CalledFunc, *CurrBB, BB))
101 bool PartiallyInlineLibCalls::optimizeSQRT(
CallInst *Call,
132 Builder.SetInsertPoint(LibCallBB);
134 Builder.Insert(LibCall);
135 Builder.CreateBr(JoinBB);
142 Builder.SetInsertPoint(&CurrBB);
143 Value *FCmp = Builder.CreateFCmpOEQ(Call, Call);
144 Builder.CreateCondBr(FCmp, JoinBB, LibCallBB);
147 Phi->addIncoming(Call, &CurrBB);
148 Phi->addIncoming(LibCall, LibCallBB);
155 return new PartiallyInlineLibCalls();
static PassRegistry * getPassRegistry()
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
virtual void getAnalysisUsage(AnalysisUsage &) const
const Function * getParent() const
Return the enclosing method, or null if none.
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.
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
ID
LLVM Calling Convention Representation.
Instruction * clone() const
Function does not access memory.
void replaceAllUsesWith(Value *V)
void addAttribute(unsigned i, Attribute::AttrKind attr)
addAttribute - adds the attribute to the list of attributes.
LLVM Basic Block Representation.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Function * getCalledFunction() const
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P)
FunctionPass * createPartiallyInlineLibCallsPass()
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=0, BasicBlock *InsertBefore=0)
Creates a new BasicBlock.
LLVMContext & getContext() const
Get the context in which this basic block lives.
LLVM Value Representation.
void initializePartiallyInlineLibCallsPass(PassRegistry &)