Go to the documentation of this file.
28 #define DEBUG_TYPE "partially-inline-libcalls"
30 DEBUG_COUNTER(PILCounter,
"partially-inline-libcalls-transform",
31 "Controls transformations in partially-inline-libcalls");
38 if (Call->onlyReadsMemory())
56 Type *Ty = Call->getType();
62 Builder.getTrue(), Call->getNextNode(),
false,
67 cast<BranchInst>(CurrBBTerm)->swapSuccessors();
74 Call->replaceAllUsesWith(Phi);
78 LibCallBB->
setName(
"call.sqrt");
79 Builder.SetInsertPoint(LibCallTerm);
85 Call->removeFnAttr(Attribute::WriteOnly);
86 Call->addFnAttr(Attribute::ReadNone);
89 Builder.SetInsertPoint(CurrBBTerm);
91 ?
Builder.CreateFCmpORD(Call, Call)
92 :
Builder.CreateFCmpOGE(Call->getOperand(0),
94 CurrBBTerm->setCondition(FCmp);
111 bool Changed =
false;
119 CallInst *Call = dyn_cast<CallInst>(&*II);
122 if (!Call || !(CalledFunc = Call->getCalledFunction()))
125 if (Call->isNoBuiltin() || Call->isStrictFP())
128 if (Call->isMustTailCall())
171 class PartiallyInlineLibCallsLegacyPass :
public FunctionPass {
192 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
194 &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
196 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
197 DT = &DTWP->getDomTree();
205 "partially-inline-libcalls",
206 "Partially inline calls to library functions",
false,
216 return new PartiallyInlineLibCallsLegacyPass();
A set of analyses that are preserved following a run of a transformation pass.
Analysis pass providing the TargetTransformInfo.
partially inline libcalls
This is an optimization pass for GlobalISel generic memory operations.
InstListType::iterator iterator
Instruction iterators...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
The instances of the Type class are immutable: once they are created, they are never changed.
static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, DominatorTree *DT)
Itanium Name Demangler i e convert the string _Z1fv into and both[sub] projects need to demangle but neither can depend on each other *libcxxabi needs the demangler to implement which is part of the itanium ABI spec *LLVM needs a copy for a bunch of and cannot rely on the system s __cxa_demangle because it a might not be and b may not be up to date on the latest language features The copy of the demangler in LLVM has some extra stuff that aren t needed in which depend on the shared generic components Despite these we want to keep the core generic demangling library identical between both copies to simplify development and testing If you re working on the generic library
LLVM Basic Block Representation.
constexpr const T * getPointer() const
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
iterator begin()
Instruction iterator methods.
Represent the analysis usage information of a pass.
partially inline Partially calls to library functions
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
static bool shouldExecute(unsigned CounterName)
Legacy analysis pass which computes a DominatorTree.
void setName(const Twine &Name)
Change the name of the value.
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
INITIALIZE_PASS_BEGIN(PartiallyInlineLibCallsLegacyPass, "partially-inline-libcalls", "Partially inline calls to library functions", false, false) INITIALIZE_PASS_END(PartiallyInlineLibCallsLegacyPass
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
DEBUG_COUNTER(PILCounter, "partially-inline-libcalls-transform", "Controls transformations in partially-inline-libcalls")
static bool optimizeSQRT(CallInst *Call, Function *CalledFunc, BasicBlock &CurrBB, Function::iterator &BB, const TargetTransformInfo *TTI, DomTreeUpdater *DTU)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
void preserve()
Mark an analysis as preserved.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
FunctionPass * createPartiallyInlineLibCallsPass()
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions inline
bool hasLocalLinkage() const
bool has(LibFunc F) const
Tests whether a library function is available.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
self_iterator getIterator()
StringRef getName() const
Return a constant reference to the value's name.
static bool runOnFunction(Function &F, bool PostInlining)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
Provides information about what library functions are available for the current target.
void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry &)
Analysis pass which computes a DominatorTree.
const BasicBlock * getParent() const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
amdgpu Simplify well known AMD library calls
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
Instruction * SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights, DominatorTree *DT, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM Value Representation.
Analysis pass providing the TargetLibraryInfo.
BasicBlockListType::iterator iterator