|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #define DEBUG_TYPE "sil-combine"
|
| 14 | + |
14 | 15 | #include "SILCombiner.h"
|
| 16 | + |
15 | 17 | #include "swift/AST/GenericSignature.h"
|
16 | 18 | #include "swift/AST/Module.h"
|
| 19 | +#include "swift/AST/SemanticAttrs.h" |
17 | 20 | #include "swift/AST/SubstitutionMap.h"
|
18 | 21 | #include "swift/Basic/Range.h"
|
19 |
| -#include "swift/AST/SemanticAttrs.h" |
20 | 22 | #include "swift/SIL/DebugUtils.h"
|
21 | 23 | #include "swift/SIL/DynamicCasts.h"
|
22 | 24 | #include "swift/SIL/InstructionUtils.h"
|
|
29 | 31 | #include "swift/SILOptimizer/Utils/CFGOptUtils.h"
|
30 | 32 | #include "swift/SILOptimizer/Utils/Existential.h"
|
31 | 33 | #include "swift/SILOptimizer/Utils/KeyPathProjector.h"
|
| 34 | +#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h" |
32 | 35 | #include "swift/SILOptimizer/Utils/ValueLifetime.h"
|
33 | 36 | #include "llvm/ADT/DenseMap.h"
|
34 | 37 | #include "llvm/ADT/SmallPtrSet.h"
|
@@ -1510,11 +1513,10 @@ bool SILCombiner::optimizeIdentityCastComposition(ApplyInst *fInverseApply,
|
1510 | 1513 | // First perform an ownership RAUW+erase of arg0 and inverse apply. The OSSA
|
1511 | 1514 | // RAUW helper will copy arg0 if needed. We need to do this before anything
|
1512 | 1515 | // else since the utility assumes OSSA is in correct form.
|
1513 |
| - if (!decltype(ownershipRAUWHelper)::canFixUpOwnershipForRAUW(fInverseApply, |
1514 |
| - arg0)) { |
| 1516 | + OwnershipRAUWHelper helper(ownershipFixupContext, fInverseApply, arg0); |
| 1517 | + if (!helper) |
1515 | 1518 | return false;
|
1516 |
| - } |
1517 |
| - ownershipRAUWHelper.replaceAllUsesAndErase(fInverseApply, arg0); |
| 1519 | + helper.perform(); |
1518 | 1520 |
|
1519 | 1521 | // Now remove the apply, inserting a destroy_value if we need to it arg0.
|
1520 | 1522 | if (fApply->getArgumentRef(0).isLifetimeEnding()) {
|
|
0 commit comments