File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3
- refs/heads/master-next: 09dcaf930859c1f75050dcc61e82d2482c2ac868
3
+ refs/heads/master-next: 0b86c1ef4311464f1894f2330432f232f4b64525
4
4
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
5
5
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
6
6
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07
Original file line number Diff line number Diff line change @@ -1784,6 +1784,33 @@ ConstantFolder::processWorkList() {
1784
1784
WorkList.insert (User);
1785
1785
}
1786
1786
1787
+ // See if we have a CondFailMessage. If we do, see if we can transform
1788
+ // it into a UTF8.
1789
+ if (auto *bi = dyn_cast<BuiltinInst>(User)) {
1790
+ if (auto kind = bi->getBuiltinKind ()) {
1791
+ if (*kind == BuiltinValueKind::CondFailMessage) {
1792
+ // See if our original instruction was a string literal inst.
1793
+ if (auto *sli = dyn_cast<StringLiteralInst>(I)) {
1794
+ if (sli->getEncoding () == StringLiteralInst::Encoding::UTF8) {
1795
+ SILBuilderWithScope builder (bi);
1796
+ auto *cfi = builder.createCondFail (
1797
+ bi->getLoc (), bi->getOperand (0 ), sli->getValue ());
1798
+ WorkList.insert (cfi);
1799
+ recursivelyDeleteTriviallyDeadInstructions (
1800
+ bi, /* force*/ true ,
1801
+ [&](SILInstruction *DeadI) { WorkList.remove (DeadI); });
1802
+ InvalidateInstructions = true ;
1803
+ continue ;
1804
+ }
1805
+ }
1806
+
1807
+ // If we weren't able to simplify into a cond_fail, add it to the
1808
+ // folded user set to see if the condfail msg is dead.
1809
+ FoldedUsers.insert (bi);
1810
+ }
1811
+ }
1812
+ }
1813
+
1787
1814
// Initialize ResultsInError as a None optional.
1788
1815
//
1789
1816
// We are essentially using this optional to represent 3 states: true,
Original file line number Diff line number Diff line change @@ -988,3 +988,19 @@ bb0:
988
988
%2 = builtin "ptrtoint_Int32"(%1 : $Builtin.RawPointer) : $Builtin.Int32
989
989
return %2 : $Builtin.Int32
990
990
}
991
+
992
+ // Make sure that we perform the transformation, but do not eliminate the int1,
993
+ // since we do not know what it is.
994
+ //
995
+ // CHECK-LABEL: sil @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () {
996
+ // CHECK-NOT: builtin
997
+ // CHECK: cond_fail
998
+ // CHECK-NOT: builtin
999
+ // CHECK: } // end sil function 'cond_fail_test'
1000
+ sil @cond_fail_test : $@convention(thin) (Builtin.Int1) -> () {
1001
+ bb0(%0 : $Builtin.Int1):
1002
+ %1 = string_literal utf8 "constant"
1003
+ %2 = builtin "condfail_message"(%0 : $Builtin.Int1, %1 : $Builtin.RawPointer) : $()
1004
+ %9999 = tuple()
1005
+ return %9999 : $()
1006
+ }
You can’t perform that action at this time.
0 commit comments