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 {
3333 // special instructions.
3434 DenseMap<const BasicBlock *, const Instruction *> FirstSpecialInsts;
3535
36- // Fills information about the given block's special instructions.
37- void fill (const BasicBlock *BB);
38-
3936#ifndef NDEBUG
4037 // / Asserts that the cached info for \p BB is up-to-date. This helps to catch
4138 // / 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(
4747 validate (BB);
4848#endif
4949
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+ }
5359 }
54- return FirstSpecialInsts[BB] ;
60+ return It-> second ;
5561}
5662
5763bool InstructionPrecedenceTracking::hasSpecialInstructions (
@@ -66,20 +72,6 @@ bool InstructionPrecedenceTracking::isPreceededBySpecialInstruction(
6672 return MaybeFirstSpecial && MaybeFirstSpecial->comesBefore (Insn);
6773}
6874
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-
8375#ifndef NDEBUG
8476void InstructionPrecedenceTracking::validate (const BasicBlock *BB) const {
8577 auto It = FirstSpecialInsts.find (BB);
You can’t perform that action at this time.
0 commit comments