1
- // ===--- MoveKillsCopyableAddressesChecker .cpp ---- ------------------------===//
1
+ // ===--- ConsumeOperatorCopyableAddressChecker .cpp ------------------------===//
2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
133
133
// /
134
134
// ===----------------------------------------------------------------------===//
135
135
136
- #define DEBUG_TYPE " sil-move-kills -copyable-addresses-checker"
136
+ #define DEBUG_TYPE " sil-consume-operator -copyable-addresses-checker"
137
137
138
138
#include " swift/AST/DiagnosticsSIL.h"
139
139
#include " swift/AST/Types.h"
171
171
172
172
using namespace swift ;
173
173
174
- static llvm::cl::opt<bool >
175
- DisableUnhandledMoveDiagnostic ( " sil-disable-unknown-moveaddr-diagnostic" );
174
+ static llvm::cl::opt<bool > DisableUnhandledConsumeOperator (
175
+ " sil-consume-operator -disable-unknown-moveaddr-diagnostic" );
176
176
177
177
// ===----------------------------------------------------------------------===//
178
178
// Utilities
@@ -245,9 +245,7 @@ struct ClosureOperandState {
245
245
// / points.
246
246
DebugValueInst *singleDebugValue = nullptr ;
247
247
248
- bool isUpwardsUse () const {
249
- return result == DownwardScanResult::ClosureUse;
250
- }
248
+ bool isUpwardsUse () const { return result == DownwardScanResult::ClosureUse; }
251
249
252
250
bool isUpwardsConsume () const {
253
251
return result == DownwardScanResult::ClosureConsume;
@@ -1552,9 +1550,9 @@ bool DataflowState::cleanupAllDestroyAddr(
1552
1550
// be defined before the value.
1553
1551
SILBuilderWithScope reinitBuilder ((*reinit)->getNextInstruction ());
1554
1552
reinitBuilder.setCurrentDebugScope (addressDebugInst->getDebugScope ());
1555
- reinitBuilder.createDebugValue (
1556
- addressDebugInst. inst -> getLoc (), address, *varInfo, false ,
1557
- /* was moved*/ true );
1553
+ reinitBuilder.createDebugValue (addressDebugInst. inst -> getLoc (), address,
1554
+ *varInfo, false ,
1555
+ /* was moved*/ true );
1558
1556
}
1559
1557
}
1560
1558
madeChange = true ;
@@ -1914,7 +1912,7 @@ void DataflowState::init() {
1914
1912
1915
1913
namespace {
1916
1914
1917
- struct MoveKillsCopyableAddressesChecker {
1915
+ struct ConsumeOperatorCopyableAddressesChecker {
1918
1916
SILFunction *fn;
1919
1917
UseState useState;
1920
1918
DataflowState dataflowState;
@@ -1924,8 +1922,8 @@ struct MoveKillsCopyableAddressesChecker {
1924
1922
applySiteToPromotedArgIndices;
1925
1923
SmallBlotSetVector<SILInstruction *, 8 > closureConsumes;
1926
1924
1927
- MoveKillsCopyableAddressesChecker (SILFunction *fn,
1928
- SILOptFunctionBuilder &funcBuilder)
1925
+ ConsumeOperatorCopyableAddressesChecker (SILFunction *fn,
1926
+ SILOptFunctionBuilder &funcBuilder)
1929
1927
: fn(fn), useState(),
1930
1928
dataflowState (funcBuilder, useState, applySiteToPromotedArgIndices,
1931
1929
closureConsumes),
@@ -1951,7 +1949,7 @@ struct MoveKillsCopyableAddressesChecker {
1951
1949
1952
1950
} // namespace
1953
1951
1954
- void MoveKillsCopyableAddressesChecker ::cloneDeferCalleeAndRewriteUses (
1952
+ void ConsumeOperatorCopyableAddressesChecker ::cloneDeferCalleeAndRewriteUses (
1955
1953
SmallVectorImpl<SILValue> &newArgs, const SmallBitVector &bitVector,
1956
1954
FullApplySite oldApplySite,
1957
1955
SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers) {
@@ -2012,7 +2010,7 @@ void MoveKillsCopyableAddressesChecker::cloneDeferCalleeAndRewriteUses(
2012
2010
oldApplySite->eraseFromParent ();
2013
2011
}
2014
2012
2015
- bool MoveKillsCopyableAddressesChecker ::performClosureDataflow (
2013
+ bool ConsumeOperatorCopyableAddressesChecker ::performClosureDataflow (
2016
2014
Operand *callerOperand, ClosureOperandState &calleeOperandState) {
2017
2015
auto fas = FullApplySite::isa (callerOperand->getUser ());
2018
2016
auto *func = fas.getCalleeFunction ();
@@ -2060,7 +2058,7 @@ bool MoveKillsCopyableAddressesChecker::performClosureDataflow(
2060
2058
// Returns true if we emitted a diagnostic and handled the single block
2061
2059
// case. Returns false if we visited all of the uses and seeded the UseState
2062
2060
// struct with the information needed to perform our interprocedural dataflow.
2063
- bool MoveKillsCopyableAddressesChecker ::performSingleBasicBlockAnalysis (
2061
+ bool ConsumeOperatorCopyableAddressesChecker ::performSingleBasicBlockAnalysis (
2064
2062
SILValue address, DebugVarCarryingInst addressDebugInst,
2065
2063
MarkUnresolvedMoveAddrInst *mvi) {
2066
2064
// First scan downwards to make sure we are move out of this block.
@@ -2215,8 +2213,8 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2215
2213
auto *next = interestingUser->getNextInstruction ();
2216
2214
SILBuilderWithScope reinitBuilder (next);
2217
2215
reinitBuilder.setCurrentDebugScope (addressDebugInst->getDebugScope ());
2218
- reinitBuilder.createDebugValue (addressDebugInst->getLoc (),
2219
- address, *varInfo, false ,
2216
+ reinitBuilder.createDebugValue (addressDebugInst->getLoc (), address,
2217
+ *varInfo, false ,
2220
2218
/* was moved*/ true );
2221
2219
}
2222
2220
}
@@ -2287,7 +2285,7 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2287
2285
return false ;
2288
2286
}
2289
2287
2290
- bool MoveKillsCopyableAddressesChecker ::check (SILValue address) {
2288
+ bool ConsumeOperatorCopyableAddressesChecker ::check (SILValue address) {
2291
2289
auto accessPathWithBase = AccessPathWithBase::compute (address);
2292
2290
auto accessPath = accessPathWithBase.accessPath ;
2293
2291
@@ -2384,8 +2382,8 @@ bool MoveKillsCopyableAddressesChecker::check(SILValue address) {
2384
2382
// Ok, we need to perform global dataflow for one of our moves. Initialize our
2385
2383
// dataflow state engine and then run the dataflow itself.
2386
2384
dataflowState.init ();
2387
- bool result = dataflowState. process (
2388
- address, addressDebugInst, closureConsumes);
2385
+ bool result =
2386
+ dataflowState. process ( address, addressDebugInst, closureConsumes);
2389
2387
return result;
2390
2388
}
2391
2389
@@ -2395,7 +2393,8 @@ bool MoveKillsCopyableAddressesChecker::check(SILValue address) {
2395
2393
2396
2394
namespace {
2397
2395
2398
- class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2396
+ class ConsumeOperatorCopyableAddressesCheckerPass
2397
+ : public SILFunctionTransform {
2399
2398
void run () override {
2400
2399
auto *fn = getFunction ();
2401
2400
auto &astContext = fn->getASTContext ();
@@ -2442,7 +2441,7 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2442
2441
2443
2442
SILOptFunctionBuilder funcBuilder (*this );
2444
2443
2445
- MoveKillsCopyableAddressesChecker checker (getFunction (), funcBuilder);
2444
+ ConsumeOperatorCopyableAddressesChecker checker (getFunction (), funcBuilder);
2446
2445
2447
2446
bool madeChange = false ;
2448
2447
while (!addressToProcess.empty ()) {
@@ -2481,7 +2480,7 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2481
2480
// uses have been resolved appropriately.
2482
2481
//
2483
2482
// TODO: Emit specific diagnostics here (e.x.: _move of global).
2484
- if (DisableUnhandledMoveDiagnostic )
2483
+ if (DisableUnhandledConsumeOperator )
2485
2484
return ;
2486
2485
2487
2486
bool lateMadeChange = false ;
@@ -2513,6 +2512,6 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2513
2512
2514
2513
} // anonymous namespace
2515
2514
2516
- SILTransform *swift::createMoveKillsCopyableAddressesChecker () {
2517
- return new MoveKillsCopyableAddressesCheckerPass ();
2515
+ SILTransform *swift::createConsumeOperatorCopyableAddressesChecker () {
2516
+ return new ConsumeOperatorCopyableAddressesCheckerPass ();
2518
2517
}
0 commit comments