diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp index 503880e3e8f0e..b086ac15a207e 100644 --- a/llvm/lib/Analysis/InlineOrder.cpp +++ b/llvm/lib/Analysis/InlineOrder.cpp @@ -223,10 +223,12 @@ class PriorityInlineOrder : public InlineOrder> { // pushed right back into the heap. For simplicity, those cases where // the desirability of a call site increases are ignored here. void adjust() { - while (updateAndCheckDecreased(Heap.front())) { - std::pop_heap(Heap.begin(), Heap.end(), isLess); + std::pop_heap(Heap.begin(), Heap.end(), isLess); + while (updateAndCheckDecreased(Heap.back())) { std::push_heap(Heap.begin(), Heap.end(), isLess); + std::pop_heap(Heap.begin(), Heap.end(), isLess); } + std::push_heap(Heap.begin(), Heap.end(), isLess); } public: