mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
InstrProf: Don't keep a large sparse list around just to zero it
The Terms vector here represented a polynomial of of all possible counters, and is used to simplify expressions when generating coverage mapping. There are a few problems with this: 1. Keeping the vector as a member is wasteful, since we clear it every time we use it. 2. Most expressions refer to a subset of the counters, so we end up iterating over a large number of zeros doing nothing a lot of the time. This updates the user of the vector to store the terms locally, and uses a sort and combine approach so that we only operate on counters that are actually used in a given expression. For small cases this makes very little difference, but in cases with a very large number of counted regions this is a significant performance fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218879 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -103,8 +103,6 @@ struct CounterExpression {
|
||||
class CounterExpressionBuilder {
|
||||
/// \brief A list of all the counter expressions
|
||||
llvm::SmallVector<CounterExpression, 16> Expressions;
|
||||
/// \brief An array of terms used in expression simplification.
|
||||
llvm::SmallVector<int, 16> Terms;
|
||||
|
||||
/// \brief Return the counter which corresponds to the given expression.
|
||||
///
|
||||
@ -113,18 +111,19 @@ class CounterExpressionBuilder {
|
||||
/// expression is added to the builder's collection of expressions.
|
||||
Counter get(const CounterExpression &E);
|
||||
|
||||
/// \brief Convert the expression tree represented by a counter
|
||||
/// into a polynomial in the form of K1Counter1 + .. + KNCounterN
|
||||
/// where K1 .. KN are integer constants that are stored in the Terms array.
|
||||
void extractTerms(Counter C, int Sign = 1);
|
||||
/// \brief Gather the terms of the expression tree for processing.
|
||||
///
|
||||
/// This collects each addition and subtraction referenced by the counter into
|
||||
/// a sequence that can be sorted and combined to build a simplified counter
|
||||
/// expression.
|
||||
void extractTerms(Counter C, int Sign,
|
||||
SmallVectorImpl<std::pair<unsigned, int>> &Terms);
|
||||
|
||||
/// \brief Simplifies the given expression tree
|
||||
/// by getting rid of algebraically redundant operations.
|
||||
Counter simplify(Counter ExpressionTree);
|
||||
|
||||
public:
|
||||
CounterExpressionBuilder(unsigned NumCounterValues);
|
||||
|
||||
ArrayRef<CounterExpression> getExpressions() const { return Expressions; }
|
||||
|
||||
/// \brief Return a counter that represents the expression
|
||||
|
Reference in New Issue
Block a user