[llvm] [Inliner] Fix bugs for partial inlining with vector (PR #101481)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 05:33:34 PDT 2024


https://github.com/joshua-arch1 created https://github.com/llvm/llvm-project/pull/101481

In the cost model of partial inlining, cost for intrinsics will be applied. However, some intrinsics for vector have invalid cost, which is not allowed for partial inlining. Instead of assertion, we directly do not do partial inlining in this circumstance to avoid compiling errors.

>From 4c85ba597664571a038c8c9405d656b3ebdb03f5 Mon Sep 17 00:00:00 2001
From: joshua-arch1 <68843032+joshua-arch1 at users.noreply.github.com>
Date: Thu, 1 Aug 2024 20:33:03 +0800
Subject: [PATCH] [Inliner] Fix bugs for partial inlining with vector

In the cost model of partial inlining, cost for intrinsics will be applied. However, some intrinsics for vector have invalid cost, which is not allowed for partial inlining. Instead of assertion, we directly do not do partial inlining in this circumstance to avoid compiling errors.
---
 llvm/lib/Transforms/IPO/PartialInlining.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index 3ca095e1520f3..effdb17370201 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -1308,8 +1308,8 @@ bool PartialInlinerImpl::tryPartialInline(FunctionCloner &Cloner) {
   InstructionCost SizeCost = std::get<0>(OutliningCosts);
   InstructionCost NonWeightedRcost = std::get<1>(OutliningCosts);
 
-  assert(SizeCost.isValid() && NonWeightedRcost.isValid() &&
-         "Expected valid costs");
+  if (!SizeCost.isValid() || !NonWeightedRcost.isValid())
+    return false;
 
   // Only calculate RelativeToEntryFreq when we are doing single region
   // outlining.



More information about the llvm-commits mailing list