Skip to content

Commit c788d94

Browse files
authored
Merge pull request swiftlang#40944 from gottesmm/pr-06ae5e8248099d29edc9368cb67beed4d9bbcb58
[addr-move-function] Fix memory safety issue found by ASAN.
2 parents f0fbb80 + c021e9b commit c788d94

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

lib/SILOptimizer/Mandatory/MoveKillsCopyableAddressesChecker.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,8 @@ bool ClosureArgDataflowState::process(
822822
for (unsigned i : indices(livenessWorklist)) {
823823
if (auto *ptr = livenessWorklist[i]) {
824824
LLVM_DEBUG(llvm::dbgs()
825-
<< "ClosureArgLivenessDataflow. Liveness User: " << *ptr);
825+
<< "ClosureArgLivenessDataflow. Final: Liveness User: "
826+
<< *ptr);
826827
state.pairedUseInsts.push_back(ptr);
827828
}
828829
}
@@ -1350,6 +1351,7 @@ bool GatherLexicalLifetimeUseVisitor::visitUse(Operand *op,
13501351
auto *func = fas.getCalleeFunction();
13511352
if (!func || !func->isDefer())
13521353
return false;
1354+
LLVM_DEBUG(llvm::dbgs() << "Found closure use: " << *op->getUser());
13531355
useState.insertClosureOperand(op);
13541356
return true;
13551357
}
@@ -1595,12 +1597,14 @@ bool DataflowState::process(
15951597
bool emittedSingleDiagnostic = false;
15961598

15971599
LLVM_DEBUG(llvm::dbgs() << "Checking Multi Block Dataflow for: " << *mvi);
1600+
LLVM_DEBUG(llvm::dbgs() << " Parent Block: bb"
1601+
<< mvi->getParent()->getDebugID() << "\n");
15981602

15991603
BasicBlockWorklist worklist(fn);
16001604
BasicBlockSetVector visitedBlocks(fn);
16011605
for (auto *succBlock : mvi->getParent()->getSuccessorBlocks()) {
16021606
LLVM_DEBUG(llvm::dbgs()
1603-
<< " SuccBlocks: " << succBlock->getDebugID() << "\n");
1607+
<< " SuccBlocks: bb" << succBlock->getDebugID() << "\n");
16041608
worklist.pushIfNotVisited(succBlock);
16051609
visitedBlocks.insert(succBlock);
16061610
}
@@ -1644,7 +1648,8 @@ bool DataflowState::process(
16441648
{
16451649
auto iter = closureUseBlocks.find(next);
16461650
if (iter != closureUseBlocks.end()) {
1647-
LLVM_DEBUG(llvm::dbgs() << " Is Use Block! Emitting Error!\n");
1651+
LLVM_DEBUG(llvm::dbgs()
1652+
<< " Is Use Block From Closure! Emitting Error!\n");
16481653
// We found one! Emit the diagnostic and continue and see if we can
16491654
// get more diagnostics.
16501655
auto &astContext = fn->getASTContext();
@@ -1825,7 +1830,7 @@ void DataflowState::init() {
18251830
}
18261831
}
18271832

1828-
for (auto closureUse : useState.closureUses) {
1833+
for (auto &closureUse : useState.closureUses) {
18291834
auto *use = closureUse.first;
18301835
auto &state = closureUse.second;
18311836
auto *user = use->getUser();

test/SILOptimizer/move_function_kills_copyable_addressonly_vars.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null
22

33
// REQUIRES: optimized_stdlib
4-
// REQUIRES: rdar87618517
5-
6-
// rdar://87618517
7-
// UNSUPPORTED: asan
84

95
import Swift
106

test/SILOptimizer/move_function_kills_copyable_loadable_vars.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null
22

33
// REQUIRES: optimized_stdlib
4-
// REQUIRES: rdar87618517
5-
6-
// rdar://87618517
7-
// UNSUPPORTED: asan
84

95
import Swift
106

0 commit comments

Comments
 (0)