Skip to content

Commit

Permalink
[ModuleInliner] Remove InlineOrder::front (NFC)
Browse files Browse the repository at this point in the history
InlineOrder::front is a remnant from the era when we had a nested
"while" loops in the module inliner, with the inner one grouping the
call sites with the same caller.

Now that we have a simple "while" loop draining the priority queue, we
can just use InlineOrder::pop.

Differential Revision: https://reviews.llvm.org/D134121
  • Loading branch information
kazutakahirata committed Sep 18, 2022
1 parent 2f8a4ac commit d3b95ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 0 additions & 2 deletions llvm/include/llvm/Analysis/InlineOrder.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ template <typename T> class InlineOrder {

virtual T pop() = 0;

virtual const_reference front() = 0;

virtual void erase_if(function_ref<bool(T)> Pred) = 0;

bool empty() { return !size(); }
Expand Down
8 changes: 0 additions & 8 deletions llvm/lib/Analysis/InlineOrder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,6 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
return Result;
}

const_reference front() override {
assert(size() > 0);
adjust();

CallBase *CB = Heap.front();
return *InlineHistoryMap.find(CB);
}

void erase_if(function_ref<bool(T)> Pred) override {
auto PredWrapper = [=](CallBase *CB) -> bool {
return Pred(std::make_pair(CB, 0));
Expand Down
13 changes: 6 additions & 7 deletions llvm/lib/Transforms/IPO/ModuleInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,21 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,

// Loop forward over all of the calls.
while (!Calls->empty()) {
Function &F = *Calls->front().first->getCaller();
(void)F;
auto P = Calls->pop();
CallBase *CB = P.first;
const int InlineHistoryID = P.second;
Function &F = *CB->getCaller();
Function &Callee = *CB->getCalledFunction();

LLVM_DEBUG(dbgs() << "Inlining calls in: " << F.getName() << "\n"
<< " Function size: " << F.getInstructionCount()
<< "\n");
(void)F;

auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
return FAM.getResult<AssumptionAnalysis>(F);
};

auto P = Calls->pop();
CallBase *CB = P.first;
const int InlineHistoryID = P.second;
Function &Callee = *CB->getCalledFunction();

if (InlineHistoryID != -1 &&
inlineHistoryIncludes(&Callee, InlineHistoryID, InlineHistory)) {
setInlineRemark(*CB, "recursive");
Expand Down

0 comments on commit d3b95ec

Please sign in to comment.