Skip to content

Commit 88ecae4

Browse files
authored
Merge pull request #27484 from gottesmm/pr-54e65bb7df68949c5e764280c80e21c6f3711062
2 parents b24f717 + 534781e commit 88ecae4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/SILOptimizer/Utils/ConstantFolding.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/SIL/SILBuilder.h"
2020
#include "swift/SILOptimizer/Utils/CastOptimizer.h"
2121
#include "swift/SILOptimizer/Utils/Local.h"
22+
#include "swift/SIL/InstructionUtils.h"
2223
#include "llvm/ADT/APFloat.h"
2324
#include "llvm/ADT/APSInt.h"
2425
#include "llvm/ADT/Statistic.h"
@@ -1527,7 +1528,11 @@ static bool
15271528
constantFoldGlobalStringTablePointerBuiltin(BuiltinInst *bi,
15281529
bool enableDiagnostics) {
15291530
// Look through string initializer to extract the string_literal instruction.
1530-
SILValue builtinOperand = bi->getOperand(0);
1531+
//
1532+
// We allow for a single borrow to be stripped here if we are here in
1533+
// [ossa]. The begin borrow occurs b/c SILGen treats builtins as having
1534+
// arguments with a +0 convention (implying a borrow).
1535+
SILValue builtinOperand = stripBorrow(bi->getOperand(0));
15311536
SILFunction *caller = bi->getFunction();
15321537

15331538
FullApplySite stringInitSite = FullApplySite::isa(builtinOperand);

test/SILOptimizer/diagnostic_constant_propagation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend -emit-sil -primary-file %s -o /dev/null -verify
2+
// RUN: %target-swift-frontend -emit-sil -enable-ownership-stripping-after-serialization -primary-file %s -o /dev/null -verify
23
//
34
// These are tests for diagnostics produced by constant propagation pass.
45
// Due to the change in the implementation of Integer initializers some of the

0 commit comments

Comments
 (0)