Skip to content

Commit 40547a1

Browse files
authored
Merge pull request #62313 from tshortli/parse-sil-has-symbol
SIL: Add parser support for `has_symbol` instructions
2 parents 2da8042 + 3e79784 commit 40547a1

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,7 +4935,6 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
49354935
SILDeclRef Member;
49364936
SILType MethodTy;
49374937
SourceLoc TyLoc;
4938-
SmallVector<ValueDecl *, 4> values;
49394938
if (parseTypedValueRef(Val, B) ||
49404939
P.parseToken(tok::comma, diag::expected_tok_in_sil_instr, ","))
49414940
return true;
@@ -6122,7 +6121,12 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
61226121
break;
61236122
}
61246123
case SILInstructionKind::HasSymbolInst: {
6125-
llvm_unreachable("unimplemented"); // FIXME: implement SIL parsing
6124+
// 'has_symbol' sil-decl-ref
6125+
SILDeclRef declRef;
6126+
if (parseSILDeclRef(declRef))
6127+
return true;
6128+
6129+
ResultVal = B.createHasSymbol(InstLoc, declRef.getDecl());
61266130
break;
61276131
}
61286132

test/SIL/Parser/has_symbol.sil

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo "public func simpleFunc() {}" > %t/has_symbol_helper.swift
3+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/has_symbol_helper.swiftmodule -parse-as-library -enable-library-evolution %t/has_symbol_helper.swift
4+
// RUN: %target-swift-frontend -emit-sil -verify %s -I %t/
5+
6+
sil_stage raw
7+
8+
import Builtin
9+
import Swift
10+
import SwiftShims
11+
12+
@_weakLinked import has_symbol_helper
13+
14+
sil hidden [ossa] @$s4test0A15GlobalFunctionsyyF : $@convention(thin) () -> () {
15+
bb0:
16+
%0 = has_symbol #simpleFunc
17+
cond_br %0, bb1, bb2
18+
19+
bb1:
20+
br bb3
21+
22+
bb2:
23+
br bb3
24+
25+
bb3:
26+
%1 = tuple ()
27+
return %1 : $()
28+
}

0 commit comments

Comments
 (0)