|
| 1 | +/*========================== begin_copyright_notice ============================ |
| 2 | + |
| 3 | +Copyright (C) 2025 Intel Corporation |
| 4 | + |
| 5 | +SPDX-License-Identifier: MIT |
| 6 | + |
| 7 | +============================= end_copyright_notice ===========================*/ |
| 8 | + |
| 9 | +This patch builds upon changes introduced in commit: |
| 10 | +https://github.com/llvm/llvm-project/commit/88da01997725f4ff1587d8944540986c42d47bf6 |
| 11 | + |
| 12 | +Original commit diagnosed an issue in the legacy inliner and claimed to fix it |
| 13 | +but the change was non-functional and only added a debug mode assert. |
| 14 | +This patch modifies it to mitigate the problem in the cases where |
| 15 | +the assert would happen. |
| 16 | + |
| 17 | +diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp |
| 18 | +index 5bcfc38c5..e7ab62d0d 100644 |
| 19 | +--- a/llvm/lib/Transforms/IPO/Inliner.cpp |
| 20 | ++++ b/llvm/lib/Transforms/IPO/Inliner.cpp |
| 21 | +@@ -533,7 +533,6 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, |
| 22 | + int NewHistoryID = InlineHistory.size(); |
| 23 | + InlineHistory.push_back(std::make_pair(Callee, InlineHistoryID)); |
| 24 | + |
| 25 | +-#ifndef NDEBUG |
| 26 | + // Make sure no dupplicates in the inline candidates. This could |
| 27 | + // happen when a callsite is simpilfied to reusing the return value |
| 28 | + // of another callsite during function cloning, thus the other |
| 29 | +@@ -541,14 +540,11 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, |
| 30 | + DenseSet<CallBase *> DbgCallSites; |
| 31 | + for (auto &II : CallSites) |
| 32 | + DbgCallSites.insert(II.first); |
| 33 | +-#endif |
| 34 | + |
| 35 | + for (Value *Ptr : InlineInfo.InlinedCalls) { |
| 36 | +-#ifndef NDEBUG |
| 37 | +- assert(DbgCallSites.count(dyn_cast<CallBase>(Ptr)) == 0); |
| 38 | +-#endif |
| 39 | +- CallSites.push_back( |
| 40 | +- std::make_pair(dyn_cast<CallBase>(Ptr), NewHistoryID)); |
| 41 | ++ if (DbgCallSites.count(dyn_cast<CallBase>(Ptr)) == 0) |
| 42 | ++ CallSites.push_back( |
| 43 | ++ std::make_pair(dyn_cast<CallBase>(Ptr), NewHistoryID)); |
| 44 | + } |
| 45 | + } |
| 46 | + } |
0 commit comments