Skip to content

Commit 328e6aa

Browse files
committed
ConstExpr: fix handling of store_borrow
The `store_borrow` instruction has a result and that must be set. Fixes a false error of the OSLogOptimization. rdar://144896232
1 parent 63b7f05 commit 328e6aa

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,10 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
18251825
return computeCallResult(apply);
18261826

18271827
if (isa<StoreInst>(inst) || isa<StoreBorrowInst>(inst)) {
1828+
if (auto *sb = dyn_cast<StoreBorrowInst>(inst)) {
1829+
auto addr = getConstantValue(inst->getOperand(1));
1830+
setValue(sb, addr);
1831+
}
18281832
auto stored = getConstantValue(inst->getOperand(0));
18291833
if (!stored.isConstant())
18301834
return stored;
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend -swift-version 6 -verify %s -emit-sil -o /dev/null
2+
3+
// REQUIRES: OS=macosx
4+
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
5+
6+
import os.log
7+
8+
let logger = Logger(subsystem: "x.y.z", category: "c")
9+
10+
// Check that this compiles without errors
11+
12+
func testit(buffer: UnsafeRawBufferPointer) {
13+
logger.fault("buffer \(buffer, privacy: .sensitive)")
14+
}

0 commit comments

Comments
 (0)