File tree Expand file tree Collapse file tree 2 files changed +10
-21
lines changed Expand file tree Collapse file tree 2 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,6 @@ class InstructionPrecedenceTracking {
33
33
// special instructions.
34
34
DenseMap<const BasicBlock *, const Instruction *> FirstSpecialInsts;
35
35
36
- // Fills information about the given block's special instructions.
37
- void fill (const BasicBlock *BB);
38
-
39
36
#ifndef NDEBUG
40
37
// / Asserts that the cached info for \p BB is up-to-date. This helps to catch
41
38
// / the usage error of accessing a block without properly invalidating after a
Original file line number Diff line number Diff line change @@ -47,11 +47,17 @@ const Instruction *InstructionPrecedenceTracking::getFirstSpecialInstruction(
47
47
validate (BB);
48
48
#endif
49
49
50
- if (!FirstSpecialInsts.contains (BB)) {
51
- fill (BB);
52
- assert (FirstSpecialInsts.contains (BB) && " Must be!" );
50
+ auto [It, Inserted] = FirstSpecialInsts.try_emplace (BB);
51
+ if (Inserted) {
52
+ for (const auto &I : *BB) {
53
+ NumInstScanned++;
54
+ if (isSpecialInstruction (&I)) {
55
+ It->second = &I;
56
+ break ;
57
+ }
58
+ }
53
59
}
54
- return FirstSpecialInsts[BB] ;
60
+ return It-> second ;
55
61
}
56
62
57
63
bool InstructionPrecedenceTracking::hasSpecialInstructions (
@@ -66,20 +72,6 @@ bool InstructionPrecedenceTracking::isPreceededBySpecialInstruction(
66
72
return MaybeFirstSpecial && MaybeFirstSpecial->comesBefore (Insn);
67
73
}
68
74
69
- void InstructionPrecedenceTracking::fill (const BasicBlock *BB) {
70
- FirstSpecialInsts.erase (BB);
71
- for (const auto &I : *BB) {
72
- NumInstScanned++;
73
- if (isSpecialInstruction (&I)) {
74
- FirstSpecialInsts[BB] = &I;
75
- return ;
76
- }
77
- }
78
-
79
- // Mark this block as having no special instructions.
80
- FirstSpecialInsts[BB] = nullptr ;
81
- }
82
-
83
75
#ifndef NDEBUG
84
76
void InstructionPrecedenceTracking::validate (const BasicBlock *BB) const {
85
77
auto It = FirstSpecialInsts.find (BB);
You can’t perform that action at this time.
0 commit comments