File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
include/swift/SILOptimizer/Analysis
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 13
13
#ifndef SWIFT_SILOPTIMIZER_ANALYSIS_ARCANALYSIS_H
14
14
#define SWIFT_SILOPTIMIZER_ANALYSIS_ARCANALYSIS_H
15
15
16
+ #include " swift/Basic/LLVM.h"
16
17
#include " swift/SIL/SILArgument.h"
17
- #include " swift/SIL/SILValue.h"
18
18
#include " swift/SIL/SILBasicBlock.h"
19
+ #include " swift/SIL/SILValue.h"
19
20
#include " swift/SILOptimizer/Analysis/AliasAnalysis.h"
20
21
#include " swift/SILOptimizer/Analysis/PostOrderAnalysis.h"
21
22
#include " swift/SILOptimizer/Analysis/RCIdentityAnalysis.h"
22
23
#include " llvm/ADT/BitVector.h"
23
- #include " llvm/ADT/SmallPtrSet.h"
24
24
#include " llvm/ADT/MapVector.h"
25
25
#include " llvm/ADT/SetVector.h"
26
+ #include " llvm/ADT/SmallPtrSet.h"
26
27
#include " llvm/ADT/TinyPtrVector.h"
27
28
28
29
namespace swift {
@@ -181,7 +182,8 @@ class ConsumedResultToEpilogueRetainMatcher {
181
182
private:
182
183
// / Return true if all the successors of the EpilogueRetainInsts do not have
183
184
// / a retain.
184
- bool isTransitiveSuccessorsRetainFree (llvm::DenseSet<SILBasicBlock *> BBs);
185
+ bool
186
+ isTransitiveSuccessorsRetainFree (const llvm::DenseSet<SILBasicBlock *> &BBs);
185
187
186
188
// / Finds matching releases in the provided block \p BB.
187
189
RetainKindValue findMatchingRetainsInBasicBlock (SILBasicBlock *BB,
Original file line number Diff line number Diff line change @@ -498,22 +498,24 @@ void ConsumedResultToEpilogueRetainMatcher::recompute() {
498
498
findMatchingRetains (&*BB);
499
499
}
500
500
501
- bool
502
- ConsumedResultToEpilogueRetainMatcher::
503
- isTransitiveSuccessorsRetainFree (llvm::DenseSet<SILBasicBlock *> BBs) {
501
+ bool ConsumedResultToEpilogueRetainMatcher::isTransitiveSuccessorsRetainFree (
502
+ const llvm::DenseSet<SILBasicBlock *> &BBs) {
504
503
// For every block with retain, we need to check the transitive
505
504
// closure of its successors are retain-free.
506
505
for (auto &I : EpilogueRetainInsts) {
507
- auto *CBB = I->getParent ();
508
- for (auto &Succ : CBB->getSuccessors ()) {
509
- if (BBs.find (Succ) != BBs.end ())
506
+ for (auto &Succ : I->getParent ()->getSuccessors ()) {
507
+ if (BBs.count (Succ))
510
508
continue ;
511
509
return false ;
512
510
}
513
511
}
512
+
513
+ // FIXME: We are iterating over a DenseSet. That can lead to non-determinism
514
+ // and is in general pretty inefficient since we are iterating over a hash
515
+ // table.
514
516
for (auto CBB : BBs) {
515
517
for (auto &Succ : CBB->getSuccessors ()) {
516
- if (BBs.find (Succ) != BBs. end ( ))
518
+ if (BBs.count (Succ))
517
519
continue ;
518
520
return false ;
519
521
}
You can’t perform that action at this time.
0 commit comments