[llvm] [InlineOrder] Fix InlineOrder erase_if implementation (PR #78684)

Vincent Lee via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 01:00:19 PST 2024


https://github.com/thevinster created https://github.com/llvm/llvm-project/pull/78684

The InlineOrder Heap stores a CallBase ptr and InlineHistoryID pair. When running the `erase_if` method, InlineHistoryID is always returned with 0. Instead, we should be retrieving it from the `InlineHistoryMap` (similar to what is done in the `pop` implementation). 

This change is completely harmless because no one is using InlineHistoryID right now as part of the `erase_if` implementation which is currently only used in the ModuleInliner. 

>From b1e3ccbd702b126a6b810893a4e14408c704028e Mon Sep 17 00:00:00 2001
From: Vincent Lee <leevince at fb.com>
Date: Fri, 19 Jan 2024 00:52:01 -0800
Subject: [PATCH] [InlineOrder] Fix InlineOrder erase_if implementation

---
 llvm/lib/Analysis/InlineOrder.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp
index d6acafdc6ab8bc6..09fc4f9a00f49cd 100644
--- a/llvm/lib/Analysis/InlineOrder.cpp
+++ b/llvm/lib/Analysis/InlineOrder.cpp
@@ -262,7 +262,7 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
 
   void erase_if(function_ref<bool(T)> Pred) override {
     auto PredWrapper = [=](CallBase *CB) -> bool {
-      return Pred(std::make_pair(CB, 0));
+      return Pred(std::make_pair(CB, InlineHistoryMap[CB]));
     };
     llvm::erase_if(Heap, PredWrapper);
     std::make_heap(Heap.begin(), Heap.end(), isLess);



More information about the llvm-commits mailing list