Skip to content

Commit 913bcb4

Browse files
committed
SimplifyCFG: Collect lookup table statistics at creation
Since the SwitchReplacement is created before we decide to replace the switch, only increase the table counters when we actually create them.
1 parent 27179dc commit 913bcb4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6619,7 +6619,6 @@ SwitchReplacement::SwitchReplacement(
66196619
(void)M.smul_ov(APInt(M.getBitWidth(), TableSize - 1), MayWrap);
66206620
LinearMapValWrapped = NonMonotonic || MayWrap;
66216621
Kind = LinearMapKind;
6622-
++NumLinearMaps;
66236622
return;
66246623
}
66256624
}
@@ -6639,7 +6638,6 @@ SwitchReplacement::SwitchReplacement(
66396638
BitMap = ConstantInt::get(M.getContext(), TableInt);
66406639
BitMapElementTy = IT;
66416640
Kind = BitMapKind;
6642-
++NumBitMaps;
66436641
return;
66446642
}
66456643

@@ -6656,6 +6654,7 @@ Value *SwitchReplacement::replaceSwitch(Value *Index, IRBuilder<> &Builder,
66566654
case SingleValueKind:
66576655
return SingleValue;
66586656
case LinearMapKind: {
6657+
++NumLinearMaps;
66596658
// Derive the result value from the input value.
66606659
Value *Result = Builder.CreateIntCast(Index, LinearMultiplier->getType(),
66616660
false, "switch.idx.cast");
@@ -6671,6 +6670,7 @@ Value *SwitchReplacement::replaceSwitch(Value *Index, IRBuilder<> &Builder,
66716670
return Result;
66726671
}
66736672
case BitMapKind: {
6673+
++NumBitMaps;
66746674
// Type of the bitmap (e.g. i59).
66756675
IntegerType *MapTy = BitMap->getIntegerType();
66766676

@@ -6693,6 +6693,7 @@ Value *SwitchReplacement::replaceSwitch(Value *Index, IRBuilder<> &Builder,
66936693
return Builder.CreateTrunc(DownShifted, BitMapElementTy, "switch.masked");
66946694
}
66956695
case LookupTableKind: {
6696+
++NumLookupTables;
66966697
auto *Table =
66976698
new GlobalVariable(*Func->getParent(), Initializer->getType(),
66986699
/*isConstant=*/true, GlobalVariable::PrivateLinkage,
@@ -7261,7 +7262,6 @@ static bool simplifySwitchLookup(SwitchInst *SI, IRBuilder<> &Builder,
72617262
if (DTU)
72627263
DTU->applyUpdates(Updates);
72637264

7264-
++NumLookupTables;
72657265
if (NeedMask)
72667266
++NumLookupTablesHoles;
72677267
return true;

0 commit comments

Comments
 (0)