@@ -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,18 @@ bool SILParserState::parseSILGlobal(Parser &P) {
75577576 SourceLoc NameLoc;
75587577 SerializedKind_t isSerialized = IsNotSerialized;
75597578 bool isMarkedAsUsed = false ;
7579+ StringRef asmName;
75607580 bool isLet = false ;
75617581
75627582 SILParser State (P);
75637583 if (parseSILLinkage (GlobalLinkage, P) ||
75647584 parseDeclSILOptional (nullptr , &isSerialized, nullptr , nullptr , nullptr ,
75657585 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
75667586 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) ||
7587+ nullptr , nullptr , nullptr , &isMarkedAsUsed, &asmName ,
7588+ nullptr , &isLet , nullptr , nullptr , nullptr , nullptr ,
7589+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7590+ State, M) ||
75717591 P.parseToken (tok::at_sign, diag::expected_sil_value_name) ||
75727592 P.parseIdentifier (GlobalName, NameLoc, /* diagnoseDollarPrefix=*/ false ,
75737593 diag::expected_sil_value_name) ||
@@ -7594,6 +7614,8 @@ bool SILParserState::parseSILGlobal(Parser &P) {
75947614
75957615 GV->setLet (isLet);
75967616 GV->setMarkedAsUsed (isMarkedAsUsed);
7617+ GV->setAsmName (asmName);
7618+
75977619 // Parse static initializer if exists.
75987620 if (State.P .consumeIf (tok::equal) && State.P .consumeIf (tok::l_brace)) {
75997621 SILBuilder B (GV);
@@ -7621,7 +7643,7 @@ bool SILParserState::parseSILProperty(Parser &P) {
76217643 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76227644 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76237645 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7624- nullptr , nullptr , nullptr , nullptr , SP, M))
7646+ nullptr , nullptr , nullptr , nullptr , nullptr , SP, M))
76257647 return true ;
76267648
76277649 ValueDecl *VD;
@@ -7691,7 +7713,8 @@ bool SILParserState::parseSILVTable(Parser &P) {
76917713 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76927714 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
76937715 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7694- nullptr , nullptr , nullptr , nullptr , VTableState, M))
7716+ nullptr , nullptr , nullptr , nullptr , nullptr ,
7717+ VTableState, M))
76957718 return true ;
76967719
76977720
@@ -7814,7 +7837,7 @@ bool SILParserState::parseSILMoveOnlyDeinit(Parser &parser) {
78147837 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78157838 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
78167839 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
7817- nullptr , nullptr , nullptr , nullptr ,
7840+ nullptr , nullptr , nullptr , nullptr , nullptr ,
78187841 moveOnlyDeinitTableState, M))
78197842 return true ;
78207843
@@ -8359,8 +8382,9 @@ bool SILParserState::parseSILWitnessTable(Parser &P) {
83598382 nullptr , &isSerialized, nullptr , nullptr , nullptr , nullptr , nullptr ,
83608383 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
83618384 nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8362- nullptr , nullptr , nullptr , nullptr , &isSpecialized, nullptr , nullptr ,
8363- nullptr , nullptr , nullptr , nullptr , nullptr , WitnessState, M))
8385+ nullptr , nullptr , nullptr , nullptr , nullptr , &isSpecialized,
8386+ nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ,
8387+ WitnessState, M))
83648388 return true ;
83658389
83668390 // Parse the protocol conformance.
0 commit comments