Skip to content

Commit 567d2a7

Browse files
committed
---
yaml --- r: 349357 b: refs/heads/master-next c: fada3bd h: refs/heads/master i: 349355: c1d785e
1 parent 14ca5ea commit 567d2a7

File tree

5 files changed

+61
-22
lines changed

5 files changed

+61
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: c431f3705a8ea3b975255f209bb75dfbe2a1fe5d
3+
refs/heads/master-next: fada3bd80b332da46e35067350221dfb587670a7
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/SILOptimizer/Utils/ConstantFolding.cpp

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,55 +1526,71 @@ constantFoldGlobalStringTablePointerBuiltin(BuiltinInst *bi,
15261526
}
15271527

15281528
/// Initialize the worklist to all of the constant instructions.
1529-
void ConstantFolder::initializeWorklist(SILFunction &F) {
1530-
for (auto &BB : F) {
1531-
for (auto &I : BB) {
1529+
void ConstantFolder::initializeWorklist(SILFunction &f) {
1530+
for (auto &block : f) {
1531+
for (auto ii = block.begin(), ie = block.end(); ii != ie; ) {
1532+
auto *inst = &*ii;
1533+
++ii;
1534+
1535+
// TODO: Eliminate trivially dead instructions here.
1536+
15321537
// If `I` is a floating-point literal instruction where the literal is
15331538
// inf, it means the input has a literal that overflows even
15341539
// MaxBuiltinFloatType. Diagnose this error, but allow this instruction
15351540
// to be folded, if needed.
1536-
if (auto floatLit = dyn_cast<FloatLiteralInst>(&I)) {
1541+
if (auto *floatLit = dyn_cast<FloatLiteralInst>(inst)) {
15371542
APFloat fpVal = floatLit->getValue();
15381543
if (EnableDiagnostics && fpVal.isInfinity()) {
15391544
SmallString<10> litStr;
15401545
tryExtractLiteralText(floatLit, litStr);
1541-
diagnose(I.getModule().getASTContext(), I.getLoc().getSourceLoc(),
1546+
diagnose(inst->getModule().getASTContext(), inst->getLoc().getSourceLoc(),
15421547
diag::warning_float_overflows_maxbuiltin, litStr,
15431548
fpVal.isNegative());
15441549
}
15451550
}
15461551

1547-
if (isFoldable(&I) && I.hasUsesOfAnyResult()) {
1548-
WorkList.insert(&I);
1552+
if (isFoldable(inst) && inst->hasUsesOfAnyResult()) {
1553+
WorkList.insert(inst);
15491554
continue;
15501555
}
15511556

15521557
// - Should we replace calls to assert_configuration by the assert
15531558
// configuration and fold calls to any cond_unreachable.
15541559
if (AssertConfiguration != SILOptions::DisableReplacement &&
1555-
(isApplyOfBuiltin(I, BuiltinValueKind::AssertConf) ||
1556-
isApplyOfBuiltin(I, BuiltinValueKind::CondUnreachable))) {
1557-
WorkList.insert(&I);
1560+
(isApplyOfBuiltin(*inst, BuiltinValueKind::AssertConf) ||
1561+
isApplyOfBuiltin(*inst, BuiltinValueKind::CondUnreachable))) {
1562+
WorkList.insert(inst);
1563+
continue;
1564+
}
1565+
1566+
if (isApplyOfBuiltin(*inst, BuiltinValueKind::GlobalStringTablePointer)) {
1567+
WorkList.insert(inst);
15581568
continue;
15591569
}
15601570

1561-
if (isApplyOfBuiltin(I, BuiltinValueKind::GlobalStringTablePointer)) {
1562-
WorkList.insert(&I);
1571+
if (isa<CheckedCastBranchInst>(inst) ||
1572+
isa<CheckedCastAddrBranchInst>(inst) ||
1573+
isa<UnconditionalCheckedCastInst>(inst) ||
1574+
isa<UnconditionalCheckedCastAddrInst>(inst)) {
1575+
WorkList.insert(inst);
15631576
continue;
15641577
}
15651578

1566-
if (isa<CheckedCastBranchInst>(&I) ||
1567-
isa<CheckedCastAddrBranchInst>(&I) ||
1568-
isa<UnconditionalCheckedCastInst>(&I) ||
1569-
isa<UnconditionalCheckedCastAddrInst>(&I)) {
1570-
WorkList.insert(&I);
1579+
if (isApplyOfStringConcat(*inst)) {
1580+
WorkList.insert(inst);
15711581
continue;
15721582
}
15731583

1574-
if (!isApplyOfStringConcat(I)) {
1584+
// If we have nominal type literals like struct, tuple, enum visit them
1585+
// like we do in the worklist to see if we can fold any projection
1586+
// manipulation operations.
1587+
if (isa<StructInst>(inst) || isa<TupleInst>(inst)) {
1588+
// TODO: Enum.
1589+
WorkList.insert(inst);
15751590
continue;
15761591
}
1577-
WorkList.insert(&I);
1592+
1593+
// ...
15781594
}
15791595
}
15801596
}

branches/master-next/stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ if(SWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING)
288288
list(APPEND swift_stdlib_compile_flags "-enforce-exclusivity=checked")
289289
endif()
290290

291+
list(APPEND swift_stdlib_compile_flags "-Xfrontend" "-enable-ownership-stripping-after-serialization")
292+
291293
if(SWIFT_CHECK_ESSENTIAL_STDLIB)
292294
add_swift_target_library(swift_stdlib_essential ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
293295
INSTALL_IN_COMPONENT never_install

branches/master-next/test/SILOptimizer/constant_propagation.sil

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,3 +1004,23 @@ bb0(%0 : $Builtin.Int1):
10041004
%9999 = tuple()
10051005
return %9999 : $()
10061006
}
1007+
1008+
// CHECK-LABEL: sil @simplify_struct_test : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
1009+
// CHECK-NOT: struct
1010+
// CHECK: } // end sil function 'simplify_struct_test'
1011+
sil @simplify_struct_test : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
1012+
bb0(%0 : $Builtin.Int64):
1013+
%1 = struct $Int64 (%0 : $Builtin.Int64)
1014+
%2 = struct_extract %1 : $Int64, #Int64.value
1015+
return %2 : $Builtin.Int64
1016+
}
1017+
1018+
// CHECK-LABEL: sil @simplify_tuple_test : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
1019+
// CHECK-NOT: tuple
1020+
// CHECK: } // end sil function 'simplify_tuple_test'
1021+
sil @simplify_tuple_test : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
1022+
bb0(%0 : $Builtin.Int64):
1023+
%1 = tuple(%0 : $Builtin.Int64, %0 : $Builtin.Int64)
1024+
%2 = tuple_extract %1 : $(Builtin.Int64, Builtin.Int64), 0
1025+
return %2 : $Builtin.Int64
1026+
}

branches/master-next/test/SILOptimizer/pound_assert.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ func test_loops() {
6767
#assert(infiniteLoop() == 1)
6868
}
6969

70-
func recursive(a: Int) -> Int {
71-
// expected-note@+1 {{limit exceeded here}}
70+
// NOTE: We currently hit the limit of 512 on a debug_value in the prelude of
71+
// this function. TODO: What is the right thing to do here?
72+
func recursive(a: Int) -> Int { // expected-note {{limit exceeded here}}
7273
return a == 0 ? 0 : recursive(a: a-1)
7374
}
7475

0 commit comments

Comments
 (0)