diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -613,7 +613,9 @@ // calls to become direct calls. // CallSites may be modified inside so ranged for loop can not be used. for (unsigned CSi = 0; CSi != CallSites.size(); ++CSi) { - CallBase &CS = *CallSites[CSi].first; + auto &P = CallSites[CSi]; + CallBase &CS = *P.first; + const int InlineHistoryID = P.second; Function *Caller = CS.getCaller(); Function *Callee = CS.getCalledFunction(); @@ -622,19 +624,14 @@ if (!Callee || Callee->isDeclaration()) continue; - Instruction *Instr = &CS; + bool IsTriviallyDead = isInstructionTriviallyDead(&CS, &GetTLI(*Caller)); - bool IsTriviallyDead = - isInstructionTriviallyDead(Instr, &GetTLI(*Caller)); - - int InlineHistoryID; if (!IsTriviallyDead) { // If this call site was obtained by inlining another function, verify // that the include path for the function did not include the callee // itself. If so, we'd be recursively inlining the same function, // which would provide the same callsites, which would cause us to // infinitely inline. - InlineHistoryID = CallSites[CSi].second; if (InlineHistoryID != -1 && inlineHistoryIncludes(Callee, InlineHistoryID, InlineHistory)) { setInlineRemark(CS, "recursive"); @@ -667,11 +664,11 @@ // size. This happens because IPSCCP propagates the result out of the // call and then we're left with the dead call. if (IsTriviallyDead) { - LLVM_DEBUG(dbgs() << " -> Deleting dead call: " << *Instr << "\n"); + LLVM_DEBUG(dbgs() << " -> Deleting dead call: " << CS << "\n"); // Update the call graph by deleting the edge from Callee to Caller. setInlineRemark(CS, "trivially dead"); CG[Caller]->removeCallEdgeFor(CS); - Instr->eraseFromParent(); + CS.eraseFromParent(); ++NumCallsDeleted; } else { // Get DebugLoc to report. CS will be invalid after Inliner. @@ -1039,9 +1036,9 @@ // call graph and prepare the context of that new caller. bool DidInline = false; for (; I < (int)Calls.size() && Calls[I].first->getCaller() == &F; ++I) { - int InlineHistoryID; - CallBase *CS = nullptr; - std::tie(CS, InlineHistoryID) = Calls[I]; + auto &P = Calls[I]; + CallBase *CS = P.first; + const int InlineHistoryID = P.second; Function &Callee = *CS->getCalledFunction(); if (InlineHistoryID != -1 &&