diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2018-05-30 19:31:11 +0000 | 
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2018-05-30 19:31:11 +0000 | 
| commit | c8bd5449e0efada29a1481451889ec069c228c7c (patch) | |
| tree | 68ad585216f093b4ae320586d65adf9f26670ffa /llvm/lib/Transforms/IPO | |
| parent | 1651ac13be81bae08365dda486263a1fec04f2d2 (diff) | |
| download | bcm5719-llvm-c8bd5449e0efada29a1481451889ec069c228c7c.tar.gz bcm5719-llvm-c8bd5449e0efada29a1481451889ec069c228c7c.zip | |
[CalledValuePropagation] Just use a sorted vector instead of a set.
The set properties are never used, so a vector is enough. No
functionality change intended.
While there add some std::moves to SparseSolver.
llvm-svn: 333582
Diffstat (limited to 'llvm/lib/Transforms/IPO')
| -rw-r--r-- | llvm/lib/Transforms/IPO/CalledValuePropagation.cpp | 20 | 
1 files changed, 11 insertions, 9 deletions
| diff --git a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp index c5f6336aa2b..1d187046ba3 100644 --- a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp +++ b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp @@ -69,12 +69,15 @@ public:    CVPLatticeVal() : LatticeState(Undefined) {}    CVPLatticeVal(CVPLatticeStateTy LatticeState) : LatticeState(LatticeState) {} -  CVPLatticeVal(std::set<Function *, Compare> &&Functions) -      : LatticeState(FunctionSet), Functions(Functions) {} +  CVPLatticeVal(std::vector<Function *> &&Functions) +      : LatticeState(FunctionSet), Functions(std::move(Functions)) { +    assert(std::is_sorted(this->Functions.begin(), this->Functions.end(), +                          Compare())); +  }    /// Get a reference to the functions held by this lattice value. The number    /// of functions will be zero for states other than FunctionSet. -  const std::set<Function *, Compare> &getFunctions() const { +  const std::vector<Function *> &getFunctions() const {      return Functions;    } @@ -99,7 +102,8 @@ private:    /// MaxFunctionsPerValue. Since most LLVM values are expected to be in    /// uninteresting states (i.e., overdefined), CVPLatticeVal objects should be    /// small and efficiently copyable. -  std::set<Function *, Compare> Functions; +  // FIXME: This could be a TinyPtrVector and/or merge with LatticeState. +  std::vector<Function *> Functions;  };  /// The custom lattice function used by the generic sparse propagation solver. @@ -150,11 +154,10 @@ public:        return getOverdefinedVal();      if (X == getUndefVal() && Y == getUndefVal())        return getUndefVal(); -    std::set<Function *, CVPLatticeVal::Compare> Union; +    std::vector<Function *> Union;      std::set_union(X.getFunctions().begin(), X.getFunctions().end(),                     Y.getFunctions().begin(), Y.getFunctions().end(), -                   std::inserter(Union, Union.begin()), -                   CVPLatticeVal::Compare{}); +                   std::back_inserter(Union), CVPLatticeVal::Compare{});      if (Union.size() > MaxFunctionsPerValue)        return getOverdefinedVal();      return CVPLatticeVal(std::move(Union)); @@ -377,8 +380,7 @@ static bool runCVP(Module &M) {      CVPLatticeVal LV = Solver.getExistingValueState(RegI);      if (!LV.isFunctionSet() || LV.getFunctions().empty())        continue; -    MDNode *Callees = MDB.createCallees(SmallVector<Function *, 4>( -        LV.getFunctions().begin(), LV.getFunctions().end())); +    MDNode *Callees = MDB.createCallees(LV.getFunctions());      C->setMetadata(LLVMContext::MD_callees, Callees);      Changed = true;    } | 

