[llvm] [WIP] Emit missed- and passed-optimization messages when partially inlining sqrt (PR #123966)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 10:39:08 PST 2025


https://github.com/TiborGY updated https://github.com/llvm/llvm-project/pull/123966

>From 00adc1d0a384e01395657bb029087f038d616182 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Wed, 22 Jan 2025 17:52:25 +0100
Subject: [PATCH] 4th try

---
 .../Transforms/Scalar/PartiallyInlineLibCalls.cpp  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
index 2b50ccdc2eeb4f..97343031e4c0e7 100644
--- a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -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: 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 "
+              "invalid inputs.";
+  });
+
   Type *Ty = Call->getType();
   IRBuilder<> Builder(Call->getNextNode());
 



More information about the llvm-commits mailing list