components/llvm/patches/006-solaris-LLVM-libLLVMAnalysis.patch
changeset 6512 92717ce71105
equal deleted inserted replaced
6511:d283aa33e131 6512:92717ce71105
       
     1 # 22902339 memory corruption caused by undefined behavior in LLVM IR Module
       
     2 # Miscellaneous cleanup fixes.
       
     3 # Replace SmallVectorImpl | SmallVector with std::vector.
       
     4 # 3.9.X upstream.
       
     5 --- include/llvm/Analysis/BlockFrequencyInfoImpl.h	2015-12-18 12:53:24.000000000 -0900
       
     6 +++ include/llvm/Analysis/BlockFrequencyInfoImpl.h	2016-07-07 10:08:31.067332185 -0800
       
     7 @@ -249,7 +249,9 @@
       
     8      LoopData *Loop; ///< The loop this block is inside.
       
     9      BlockMass Mass; ///< Mass distribution from the entry block.
       
    10  
       
    11 -    WorkingData(const BlockNode &Node) : Node(Node), Loop(nullptr) {}
       
    12 +    WorkingData() : Node(), Loop(nullptr), Mass() { }
       
    13 +    WorkingData(const BlockNode &Node) : Node(Node), Loop(nullptr), Mass() { }
       
    14 +    ~WorkingData() { }
       
    15  
       
    16      bool isLoopHeader() const { return Loop && Loop->isHeader(Node); }
       
    17      bool isDoubleLoopHeader() const {
       
    18 @@ -332,9 +334,10 @@
       
    19      DistType Type;
       
    20      BlockNode TargetNode;
       
    21      uint64_t Amount;
       
    22 -    Weight() : Type(Local), Amount(0) {}
       
    23 +    Weight() : Type(Local), TargetNode(), Amount(0ULL) { }
       
    24      Weight(DistType Type, BlockNode TargetNode, uint64_t Amount)
       
    25 -        : Type(Type), TargetNode(TargetNode), Amount(Amount) {}
       
    26 +    : Type(Type), TargetNode(TargetNode), Amount(Amount) { }
       
    27 +    ~Weight() { }
       
    28    };
       
    29  
       
    30    /// \brief Distribution of unscaled probability weight.
       
    31 @@ -985,7 +988,9 @@
       
    32  
       
    33  template <class BT> void BlockFrequencyInfoImpl<BT>::initializeRPOT() {
       
    34    const BlockT *Entry = &F->front();
       
    35 -  RPOT.reserve(F->size());
       
    36 +  if (F->size())
       
    37 +    RPOT.reserve(F->size());
       
    38 +
       
    39    std::copy(po_begin(Entry), po_end(Entry), std::back_inserter(RPOT));
       
    40    std::reverse(RPOT.begin(), RPOT.end());
       
    41  
       
    42 @@ -999,7 +1004,9 @@
       
    43      Nodes[*I] = Node;
       
    44    }
       
    45  
       
    46 -  Working.reserve(RPOT.size());
       
    47 +  if (RPOT.size())
       
    48 +    Working.reserve(RPOT.size());
       
    49 +
       
    50    for (size_t Index = 0; Index < RPOT.size(); ++Index)
       
    51      Working.emplace_back(Index);
       
    52    Freqs.resize(RPOT.size());
       
    53 
       
    54 ###
       
    55 --- lib/Analysis/LazyCallGraph.cpp	2015-12-27 20:54:20.000000000 -0500
       
    56 +++ lib/Analysis/LazyCallGraph.cpp	2016-05-28 13:36:41.670887743 -0400
       
    57 @@ -234,7 +234,7 @@
       
    58    ConnectedSCCs.insert(&CallerC);
       
    59  
       
    60    // We build up a DFS stack of the parents chains.
       
    61 -  SmallVector<std::pair<SCC *, SCC::parent_iterator>, 8> DFSSCCs;
       
    62 +  std::vector<std::pair<SCC *, SCC::parent_iterator> > DFSSCCs;
       
    63    SmallPtrSet<SCC *, 8> VisitedSCCs;
       
    64    int ConnectedDepth = -1;
       
    65    SCC *C = this;
       
    66 @@ -265,7 +265,7 @@
       
    67      // If we've found a connection anywhere below this point on the stack (and
       
    68      // thus up the parent graph from the caller), the current node needs to be
       
    69      // added to the connected set now that we've processed all of its parents.
       
    70 -    if ((int)DFSSCCs.size() == ConnectedDepth) {
       
    71 +    if (static_cast<int>(DFSSCCs.size()) == ConnectedDepth) {
       
    72        --ConnectedDepth; // We're finished with this connection.
       
    73        ConnectedSCCs.insert(C);
       
    74      } else {
       
    75 @@ -279,8 +279,9 @@
       
    76        break; // We've walked all the parents of the caller transitively.
       
    77  
       
    78      // Pop off the prior node and position to unwind the depth first recursion.
       
    79 -    std::tie(C, I) = DFSSCCs.pop_back_val();
       
    80 +    std::tie(C, I) = DFSSCCs.back();
       
    81      E = C->parent_end();
       
    82 +    DFSSCCs.pop_back();
       
    83    }
       
    84  
       
    85    // Now that we have identified all of the SCCs which need to be merged into
       
    86 ###
       
    87 --- lib/Analysis/CFG.cpp	2015-11-20 15:02:06.000000000 -0800
       
    88 +++ lib/Analysis/CFG.cpp	2016-05-24 19:44:24.894893025 -0700
       
    89 @@ -19,6 +19,8 @@
       
    90  
       
    91  using namespace llvm;
       
    92  
       
    93 +#include <vector>
       
    94 +
       
    95  /// FindFunctionBackedges - Analyze the specified function to find all of the
       
    96  /// loop backedges in the function and return them.  This is a relatively cheap
       
    97  /// (compared to computing dominators and loop info) analysis.
       
    98 @@ -31,7 +33,7 @@
       
    99      return;
       
   100  
       
   101    SmallPtrSet<const BasicBlock*, 8> Visited;
       
   102 -  SmallVector<std::pair<const BasicBlock*, succ_const_iterator>, 8> VisitStack;
       
   103 +  std::vector<std::pair<const BasicBlock*, succ_const_iterator> > VisitStack;
       
   104    SmallPtrSet<const BasicBlock*, 8> InStack;
       
   105  
       
   106    Visited.insert(BB);
       
   107 @@ -60,7 +62,10 @@
       
   108        VisitStack.push_back(std::make_pair(BB, succ_begin(BB)));
       
   109      } else {
       
   110        // Go up one level.
       
   111 -      InStack.erase(VisitStack.pop_back_val().first);
       
   112 +      std::pair<const BasicBlock*, succ_const_iterator> &Back =
       
   113 +        VisitStack.back();
       
   114 +      InStack.erase(Back.first);
       
   115 +      VisitStack.pop_back();
       
   116      }
       
   117    } while (!VisitStack.empty());
       
   118  }