diff --git a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp --- a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp +++ b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp @@ -19,7 +19,6 @@ #include "llvm/Transforms/IPO/CalledValuePropagation.h" #include "llvm/Analysis/SparsePropagation.h" #include "llvm/Analysis/ValueLatticeUtils.h" -#include "llvm/IR/InstVisitor.h" #include "llvm/IR/MDBuilder.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CommandLine.h" @@ -172,9 +171,8 @@ SparseSolver &SS) override { switch (I.getOpcode()) { case Instruction::Call: - return visitCallSite(cast(&I), ChangedValues, SS); case Instruction::Invoke: - return visitCallSite(cast(&I), ChangedValues, SS); + return visitCallBase(cast(I), ChangedValues, SS); case Instruction::Load: return visitLoad(*cast(&I), ChangedValues, SS); case Instruction::Ret: @@ -216,13 +214,13 @@ /// We collect a set of indirect calls when visiting call sites. This method /// returns a reference to that set. - SmallPtrSetImpl &getIndirectCalls() { return IndirectCalls; } + SmallPtrSetImpl &getIndirectCalls() { return IndirectCalls; } private: /// Holds the indirect calls we encounter during the analysis. We will attach /// metadata to these calls after the analysis indicating the functions the /// calls can possibly target. - SmallPtrSet IndirectCalls; + SmallPtrSet IndirectCalls; /// Compute a new lattice value for the given constant. The constant, after /// stripping any pointer casts, should be a Function. We ignore null @@ -254,23 +252,22 @@ /// the merge of the argument state with the call sites corresponding actual /// argument state. The call site state is the merge of the call site state /// with the returned value state of the called function. - void visitCallSite(CallSite CS, + void visitCallBase(CallBase &CB, DenseMap &ChangedValues, SparseSolver &SS) { - Function *F = CS.getCalledFunction(); - Instruction *I = CS.getInstruction(); - auto RegI = CVPLatticeKey(I, IPOGrouping::Register); + Function *F = CB.getCalledFunction(); + auto RegI = CVPLatticeKey(&CB, IPOGrouping::Register); // If this is an indirect call, save it so we can quickly revisit it when // attaching metadata. if (!F) - IndirectCalls.insert(I); + IndirectCalls.insert(&CB); // If we can't track the function's return values, there's nothing to do. if (!F || !canTrackReturnsInterprocedurally(F)) { // Void return, No need to create and update CVPLattice state as no one // can use it. - if (I->getType()->isVoidTy()) + if (CB.getType()->isVoidTy()) return; ChangedValues[RegI] = getOverdefinedVal(); return; @@ -283,14 +280,14 @@ for (Argument &A : F->args()) { auto RegFormal = CVPLatticeKey(&A, IPOGrouping::Register); auto RegActual = - CVPLatticeKey(CS.getArgument(A.getArgNo()), IPOGrouping::Register); + CVPLatticeKey(CB.getArgOperand(A.getArgNo()), IPOGrouping::Register); ChangedValues[RegFormal] = MergeValues(SS.getValueState(RegFormal), SS.getValueState(RegActual)); } // Void return, No need to create and update CVPLattice state as no one can // use it. - if (I->getType()->isVoidTy()) + if (CB.getType()->isVoidTy()) return; ChangedValues[RegI] = @@ -387,9 +384,8 @@ // the set of functions they can possibly target. bool Changed = false; MDBuilder MDB(M.getContext()); - for (Instruction *C : Lattice.getIndirectCalls()) { - CallSite CS(C); - auto RegI = CVPLatticeKey(CS.getCalledValue(), IPOGrouping::Register); + for (CallBase *C : Lattice.getIndirectCalls()) { + auto RegI = CVPLatticeKey(C->getCalledValue(), IPOGrouping::Register); CVPLatticeVal LV = Solver.getExistingValueState(RegI); if (!LV.isFunctionSet() || LV.getFunctions().empty()) continue;