-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[PartiallyInlineLibCalls] Emit missed- and passed-optimization remarks when partially inlining sqrt #123966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[PartiallyInlineLibCalls] Emit missed- and passed-optimization remarks when partially inlining sqrt #123966
Changes from 1 commit
12e8f4a
fb45df1
ce81d5c
1285745
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,20 @@ static bool optimizeSQRT(CallInst *Call, Function *CalledFunc, | |
| // dst = phi(v0, v1) | ||
| // | ||
|
|
||
| ORE->emit([&]() { | ||
| return OptimizationRemark(DEBUG_TYPE, "SqrtPartiallyInlined", | ||
| Call->getDebugLoc(), &CurrBB) | ||
| << "Partially inlined call to sqrt function despite having to use " | ||
| "errno for error handling: target has fast sqrt instruction"; | ||
|
||
| }); | ||
| ORE->emit([&]() { | ||
| return OptimizationRemarkMissed(DEBUG_TYPE, "BranchInserted", | ||
| Call->getDebugLoc(), &CurrBB) | ||
| << "Branch to library sqrt fn had to be inserted to satisfy the " | ||
| "current target's requirement for math functions to set errno on " | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a property of the target. I also don't see why these two remarks are emitted under the same exact conditions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, target may not be the best word for it indeed, but the docs are using a similar language:
I guess I could say target triplet instead of target? I have created two remarks so I can split them into an optimization passed/missed pair. In my mental model, passed means "LLVM did some profitable transformation" and missed means "something is inhibiting an optimization that could have been profitable" or "LLVM thinks something is not profitable". In this case, applying the partial inlining with the branch is simultaneously both: profitable but could have been better if setting errno wasn't a requirement. |
||
| "invalid inputs"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if the Or maybe just use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I can see how this could be a matter of interpretation. I have felt the need to separate the two messages as they convey two different aspects of the same event. Perhaps my mental model is wrong, but to me
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If my explanation is satisfactory, and there are no further concerns to be discussed, may I request a merge? |
||
| }); | ||
|
|
||
| Type *Ty = Call->getType(); | ||
| IRBuilder<> Builder(Call->getNextNode()); | ||
|
|
||
|
|
@@ -125,11 +139,29 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI, | |
| if (!Call || !(CalledFunc = Call->getCalledFunction())) | ||
| continue; | ||
|
|
||
| if (Call->isNoBuiltin() || Call->isStrictFP()) | ||
| if (Call->isNoBuiltin()) | ||
| continue; | ||
|
|
||
| if (Call->isMustTailCall()) | ||
| if (Call->isStrictFP()) { | ||
| ORE->emit([&]() { | ||
| return OptimizationRemarkMissed(DEBUG_TYPE, "StrictFloat", | ||
| Call->getDebugLoc(), &*CurrBB) | ||
| << "Could not consider library function for partial inlining:" | ||
| " strict FP exception behavior is active"; | ||
| }); | ||
| continue; | ||
| } | ||
| // Partially inlining a libcall that has the musttail attribute leads to | ||
| // broken LLVM IR, triggering an assertion in the IR verifier. | ||
| // Work around that by forgoing this optimization for musttail calls. | ||
| if (Call->isMustTailCall()) { | ||
| ORE->emit([&]() { | ||
| return OptimizationRemarkMissed(DEBUG_TYPE, "MustTailCall", | ||
| Call->getDebugLoc(), &*CurrBB) | ||
| << "Could not consider library function for partial inlining:" | ||
| " must tail call"; | ||
| }); | ||
| continue; | ||
| } | ||
|
|
||
| // Skip if function either has local linkage or is not a known library | ||
| // function. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.