mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
InstrProf: Avoid linear search in a hot loop
Every time we were adding or removing an expression when generating a coverage mapping we were doing a linear search to try and deduplicate the list. The indices in the list are important, so we can't just replace it by a DenseMap entirely, but an auxilliary DenseMap for fast lookup massively improves the performance issues I was seeing here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218892 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -28,12 +28,13 @@ using namespace coverage;
|
||||
#define DEBUG_TYPE "coverage-mapping"
|
||||
|
||||
Counter CounterExpressionBuilder::get(const CounterExpression &E) {
|
||||
for (unsigned I = 0, S = Expressions.size(); I < S; ++I) {
|
||||
if (Expressions[I] == E)
|
||||
return Counter::getExpression(I);
|
||||
}
|
||||
auto It = ExpressionIndices.find(E);
|
||||
if (It != ExpressionIndices.end())
|
||||
return Counter::getExpression(It->second);
|
||||
unsigned I = Expressions.size();
|
||||
Expressions.push_back(E);
|
||||
return Counter::getExpression(Expressions.size() - 1);
|
||||
ExpressionIndices[E] = I;
|
||||
return Counter::getExpression(I);
|
||||
}
|
||||
|
||||
void CounterExpressionBuilder::extractTerms(
|
||||
|
Reference in New Issue
Block a user