@@ -56,6 +56,20 @@ static bool optimizeSQRT(CallInst *Call, Function *CalledFunc,
5656 // dst = phi(v0, v1)
5757 //
5858
59+ ORE->emit ([&]() {
60+ return OptimizationRemark (DEBUG_TYPE, " SqrtPartiallyInlined" ,
61+ Call->getDebugLoc (), &CurrBB)
62+ << " Partially inlined call to sqrt function despite having to use "
63+ " errno for error handling: target has fast sqrt instruction" ;
64+ });
65+ ORE->emit ([&]() {
66+ return OptimizationRemarkMissed (DEBUG_TYPE, " BranchInserted" ,
67+ Call->getDebugLoc (), &CurrBB)
68+ << " Branch to library sqrt fn had to be inserted to satisfy the "
69+ " current target's requirement for math functions to set errno on "
70+ " invalid inputs" ;
71+ });
72+
5973 Type *Ty = Call->getType ();
6074 IRBuilder<> Builder (Call->getNextNode ());
6175
@@ -125,18 +139,35 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
125139 if (!Call || !(CalledFunc = Call->getCalledFunction ()))
126140 continue ;
127141
128- if (Call->isNoBuiltin () || Call->isStrictFP ())
129- continue ;
130-
131- if (Call->isMustTailCall ())
132- continue ;
133-
134142 // Skip if function either has local linkage or is not a known library
135143 // function.
136144 LibFunc LF;
137145 if (CalledFunc->hasLocalLinkage () ||
138146 !TLI->getLibFunc (*CalledFunc, LF) || !TLI->has (LF))
139147 continue ;
148+ if (Call->isNoBuiltin ())
149+ continue ;
150+ if (Call->isStrictFP ()) {
151+ ORE->emit ([&]() {
152+ return OptimizationRemarkMissed (DEBUG_TYPE, " StrictFloat" ,
153+ Call->getDebugLoc (), &*CurrBB)
154+ << " Could not consider library function for partial inlining:"
155+ " strict FP exception behavior is active" ;
156+ });
157+ continue ;
158+ }
159+ // Partially inlining a libcall that has the musttail attribute leads to
160+ // broken LLVM IR, triggering an assertion in the IR verifier.
161+ // Work around that by forgoing this optimization for musttail calls.
162+ if (Call->isMustTailCall ()) {
163+ ORE->emit ([&]() {
164+ return OptimizationRemarkMissed (DEBUG_TYPE, " MustTailCall" ,
165+ Call->getDebugLoc (), &*CurrBB)
166+ << " Could not consider library function for partial inlining:"
167+ " must tail call" ;
168+ });
169+ continue ;
170+ }
140171
141172 switch (LF) {
142173 case LibFunc_sqrtf:
0 commit comments