@@ -679,7 +679,8 @@ static bool parseDeclSILOptional(
679679 SILFunction **usedAdHocRequirementWitness, Identifier *objCReplacementFor,
680680 SILFunction::Purpose *specialPurpose, Inline_t *inlineStrategy,
681681 OptimizationMode *optimizationMode, PerformanceConstraints *perfConstraints,
682- bool *isPerformanceConstraint, bool *markedAsUsed, StringRef *section,
682+ bool *isPerformanceConstraint, bool *markedAsUsed, StringRef *asmName,
683+ StringRef *section,
683684 bool *isLet, bool *isWeakImported, bool *needStackProtection,
684685 bool *isSpecialized, AvailabilityRange *availability,
685686 bool *isWithoutActuallyEscapingThunk,
@@ -807,6 +808,20 @@ static bool parseDeclSILOptional(
807808 }
808809 *actorIsolation = *optIsolation;
809810 SP.P .consumeToken (tok::string_literal);
811+ SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
812+ continue ;
813+ } else if (asmName && SP.P .Tok .getText () == " asmname" ) {
814+ SP.P .consumeToken (tok::identifier);
815+ if (SP.P .Tok .getKind () != tok::string_literal) {
816+ SP.P .diagnose (SP.P .Tok , diag::expected_in_attribute_list);
817+ return true ;
818+ }
819+
820+ // Drop the double quotes.
821+ StringRef rawString = SP.P .Tok .getText ().drop_front ().drop_back ();
822+ *asmName = SP.P .Context .getIdentifier (rawString).str ();
823+ SP.P .consumeToken (tok::string_literal);
824+
810825 SP.P .parseToken (tok::r_square, diag::expected_in_attribute_list);
811826 continue ;
812827 } else if (section && SP.P .Tok .getText () == " section" ) {
@@ -7288,6 +7303,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
72887303 PerformanceConstraints perfConstr = PerformanceConstraints::None;
72897304 bool isPerformanceConstraint = false ;
72907305 bool markedAsUsed = false ;
7306+ StringRef asmName;
72917307 StringRef section;
72927308 SmallVector<std::string, 1 > Semantics;
72937309 SmallVector<ParsedSpecAttr, 4 > SpecAttrs;
@@ -7306,7 +7322,7 @@ bool SILParserState::parseDeclSIL(Parser &P) {
73067322 &DynamicallyReplacedFunction, &AdHocWitnessFunction,
73077323 &objCReplacementFor, &specialPurpose, &inlineStrategy,
73087324 &optimizationMode, &perfConstr, &isPerformanceConstraint,
7309- &markedAsUsed, §ion, nullptr , &isWeakImported,
7325+ &markedAsUsed, &asmName, & section, nullptr , &isWeakImported,
73107326 &needStackProtection, nullptr , &availability,
73117327 &isWithoutActuallyEscapingThunk, &Semantics, &SpecAttrs, &ClangDecl,
73127328 &MRK, &actorIsolation, FunctionState, M) ||
@@ -7363,6 +7379,9 @@ bool SILParserState::parseDeclSIL(Parser &P) {
73637379 FunctionState.F ->setPerfConstraints (perfConstr);
73647380 FunctionState.F ->setIsPerformanceConstraint (isPerformanceConstraint);
73657381 FunctionState.F ->setEffectsKind (MRK);
7382+ FunctionState.F ->setMarkedAsUsed (markedAsUsed);
7383+ FunctionState.F ->setAsmName (asmName);
7384+ FunctionState.F ->setSection (section);
73667385
73677386 if (ClangDecl)
73687387 FunctionState.F ->setClangNodeOwner (ClangDecl);
@@ -7557,17 +7576,19 @@ bool SILParserState::parseSILGlobal(Parser &P) {
75577576 SourceLoc NameLoc;
75587577 SerializedKind_t isSerialized = IsNotSerialized;
75597578 bool isMarkedAsUsed = false ;
7579+ StringRef asmName;
7580+ StringRef section;
75607581 bool isLet = false ;
75617582
75627583 SILParser State (P);
75637584 if (parseSILLinkage (GlobalLinkage, P) ||
75647585 parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
75657586 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
75667587 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7567- nullptr , nullptr , nullptr , &isMarkedAsUsed, nullptr ,
7568- &isLet, nullptr , nullptr , nullptr , nullptr , nullptr ,
7569- nullptr , nullptr , nullptr , nullptr , nullptr , State ,
7570- M) ||
7588+ nullptr , nullptr , nullptr , &isMarkedAsUsed, &asmName ,
7589+ §ion, &isLet , nullptr , nullptr , nullptr , nullptr ,
7590+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7591+ State, M) ||
75717592 P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
75727593 P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
75737594 diag::expected_sil_value_name) ||
@@ -7594,6 +7615,9 @@ bool SILParserState::parseSILGlobal(Parser &P) {
75947615
75957616 GV->setLet (isLet);
75967617 GV->setMarkedAsUsed (isMarkedAsUsed);
7618+ GV->setAsmName (asmName);
7619+ GV->setSection (section);
7620+
75977621 // Parse static initializer if exists.
75987622 if (State.P .consumeIf (tok::equal) && State.P .consumeIf (tok::l_brace)) {
75997623 SILBuilder B (GV);
@@ -7621,7 +7645,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
76217645 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76227646 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76237647 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7624- nullptr , nullptr , nullptr , nullptr , SP, M))
7648+ nullptr , nullptr , nullptr , nullptr , nullptr , SP, M))
76257649 return true ;
76267650
76277651 ValueDecl *VD;
@@ -7691,7 +7715,8 @@ bool SILParserState::parseSILVTable(Parser &P) {
76917715 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76927716 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76937717 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7694- nullptr , nullptr , nullptr , nullptr , VTableState, M))
7718+ nullptr , nullptr , nullptr , nullptr , nullptr ,
7719+ VTableState, M))
76957720 return true ;
76967721
76977722
@@ -7814,7 +7839,7 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
78147839 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78157840 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78167841 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7817- nullptr , nullptr , nullptr , nullptr ,
7842+ nullptr , nullptr , nullptr , nullptr , nullptr ,
78187843 moveOnlyDeinitTableState, M))
78197844 return true ;
78207845
@@ -8359,8 +8384,9 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
83598384 nullptr , &isSerialized, nullptr , nullptr , nullptr , nullptr , nullptr ,
83608385 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
83618386 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8362- nullptr , nullptr , nullptr , nullptr , &isSpecialized, nullptr , nullptr ,
8363- nullptr , nullptr , nullptr , nullptr , nullptr , WitnessState, M))
8387+ nullptr , nullptr , nullptr , nullptr , nullptr , &isSpecialized,
8388+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8389+ WitnessState, M))
83648390 return true ;
83658391
83668392 // Parse the protocol conformance.
0 commit comments