Skip to content

Commit 7bad558

Browse files
author
Marc Rasi
committed
remove the Builtin.staticAssert from SIL
1 parent b2fb06d commit 7bad558

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/SILOptimizer/Mandatory/IRGenPrepare.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
///
1717
/// We perform the following canonicalizations:
1818
///
19-
/// 1. We remove calls to Builtin.staticReport(), which are not needed post SIL.
19+
/// 1. We remove calls to Builtin.poundAssert() and Builtin.staticReport(),
20+
/// which are not needed post SIL.
2021
///
2122
//===----------------------------------------------------------------------===//
2223

@@ -41,14 +42,15 @@ static bool cleanFunction(SILFunction &fn) {
4142
SILInstruction *inst = &*i;
4243
++i;
4344

44-
// Remove calls to Builtin.staticReport().
45+
// Remove calls to Builtin.staticReport() and Builtin.staticReport().
4546
auto *bi = dyn_cast<BuiltinInst>(inst);
4647
if (!bi) {
4748
continue;
4849
}
4950

5051
const BuiltinInfo &bInfo = bi->getBuiltinInfo();
51-
if (bInfo.ID != BuiltinValueKind::StaticReport) {
52+
if (bInfo.ID != BuiltinValueKind::PoundAssert &&
53+
bInfo.ID != BuiltinValueKind::StaticReport) {
5254
continue;
5355
}
5456

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend -enable-experimental-static-assert -emit-silgen %s | %target-sil-opt -irgen-prepare | %FileCheck %s
2+
3+
// Tests that mandatory SIL passes remove the builtin poundAssert instruction.
4+
// CHECK-LABEL: pound_assert_removed14builtinRemoved
5+
public func builtinRemoved() {
6+
#assert(true)
7+
// CHECK-NOT: builtin "poundAssert"
8+
}

0 commit comments

Comments
 (0)