# HG changeset patch # User matac # Date 1691743116 -32400 # Node ID 861b2bbafe0aa7f81c374845ec0173828df34a4d # Parent a916df8444bf999f806a8d4c1e61c8d532b783ac fix ParseCbC diff -r a916df8444bf -r 861b2bbafe0a clang/lib/Parse/ParseCbC.cpp --- a/clang/lib/Parse/ParseCbC.cpp Fri Aug 11 15:57:02 2023 +0900 +++ b/clang/lib/Parse/ParseCbC.cpp Fri Aug 11 17:38:36 2023 +0900 @@ -288,7 +288,7 @@ ParsedType CastTy; DeclSpec void_DS(AttrFactory); setTST(&void_DS, DeclSpec::TST_void); - Declarator DeclaratorInfo(void_DS, DeclaratorContext::TypeName); + Declarator DeclaratorInfo(void_DS, ParsedAttributesView::none(), DeclaratorContext::TypeName); DeclSpec star_DS(AttrFactory); star_DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy()); DeclaratorInfo.ExtendWithDeclSpec(star_DS); @@ -366,7 +366,9 @@ DSp = &DS; setTST(&DS, valueType, Name, TQ); - ParsingDeclarator D(*this, DS, static_cast(DeclaratorContext::Block)); + ParsedAttributes LocalAttrs(AttrFactory); + // LocalAttrs.takeAllFrom(Attrs); + ParsingDeclarator D(*this, DS, LocalAttrs, static_cast(DeclaratorContext::Block)); D.SetIdentifier(II, Loc); if (array) { @@ -549,7 +551,7 @@ InnerScope.Exit(); IfScope.Exit(); StmtResult ElseStmt; - IfRes = Actions.ActOnIfStmt(Loc, false, Loc, CondExp.get(), Cond, Loc, ThenStmt.get(),Loc, ElseStmt.get()); + IfRes = Actions.ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, CondExp.get(), Cond, Loc, ThenStmt.get(),Loc, ElseStmt.get()); return IfRes; } @@ -609,7 +611,7 @@ DeclResult TagOrTempResult = true; bool Owned = false; bool IsDependent = false; - ParsedAttributesWithRange attrs(AttrFactory); + ParsedAttributes attrs(AttrFactory); MultiTemplateParamsArg TParams; TagOrTempResult = Actions.ActOnTag(getCurScope(), TagType, Sema::TUK_Definition, Loc, @@ -641,7 +643,9 @@ ParsingDeclSpec PDS(*this); setTST(&PDS, T); SourceLocation CommaLoc; - ParsingFieldDeclarator DeclaratorInfo(*this, PDS); + ParsedAttributes LocalAttrs(AttrFactory); + // LocalAttrs.takeAllFrom(Attrs); + ParsingFieldDeclarator DeclaratorInfo(*this, PDS, LocalAttrs); DeclaratorInfo.D.setCommaLoc(CommaLoc); DeclaratorInfo.D.SetRangeEnd(Loc); DeclSpec DS(AttrFactory); @@ -717,7 +721,9 @@ SourceLocation Loc = Tok.getLocation(); ParsingDeclSpec PDS(*this); setTST(&PDS, DeclSpec::TST___code); - ParsingDeclarator D(*this, PDS, static_cast(DeclaratorContext::File)); + ParsedAttributes LocalAttrs(AttrFactory); + // LocalAttrs.takeAllFrom(Attrs); + ParsingDeclarator D(*this, PDS, LocalAttrs, static_cast(DeclaratorContext::File)); D.SetIdentifier(csName, Loc); ParseScope PrototypeScope(this,Scope::FunctionPrototypeScope|Scope::DeclScope|Scope::FunctionDeclarationScope); bool IsAmbiguous = false; @@ -776,7 +782,7 @@ IdentifierInfo *structName = CreateIdentifierInfo(__CBC_STRUCT_NAME, Loc); setTST(&envDS, DeclSpec::TST_struct, structName); - Declarator envDInfo(envDS, DeclaratorContext::TypeName); + Declarator envDInfo(envDS, ParsedAttributesView::none(), DeclaratorContext::TypeName); envDInfo.SetRangeEnd(Loc); DeclSpec starDS(AttrFactory); starDS.Finish(Actions, Policy); @@ -823,7 +829,7 @@ DeclSpec ljDS(AttrFactory); setTST(&ljDS, DeclSpec::TST_struct, structName); - Declarator ljD(ljDS, DeclaratorContext::TypeName); + Declarator ljD(ljDS, ParsedAttributesView::none(), DeclaratorContext::TypeName); ljD.SetRangeEnd(Loc); DeclSpec starDS2(AttrFactory); starDS2.Finish(Actions, Policy); @@ -920,7 +926,7 @@ SourceLocation Loc = Tok.getLocation(); DeclSpec DS(AttrFactory); setTST(&DS, T); - Declarator ParamDeclarator(DS, DeclaratorContext::Prototype); + Declarator ParamDeclarator(DS, ParsedAttributesView::none(), DeclaratorContext::Prototype); ParamDeclarator.SetIdentifier(II, Loc); for(int i = 0;i(Actions.Context.getTranslationUnitDecl()); - Scope *TopScope = getCurScope(); - while(TopScope->getParent() != NULL) - TopScope = TopScope->getParent(); - Actions.CurScope = TopScope; - - Token Next = NextToken(); - Token CachedTokens[3] = {Next, PP.LookAhead(1)}; - Token SavedToken = Tok; - Token IITok = Tok.is(tok::identifier) ? Tok : Next; - PP.ClearCache(); - PP.ProtoParsing = true; - ProtoParsing = true; - - const DirectoryLookup *CurDir = nullptr; - FileID FID = PP.getSourceManager().createFileID(PP.getCurrentFileLexer()->getFileEntry(), IITok.getLocation(), SrcMgr::C_User); - PP.EnterSourceFile(FID,CurDir,IITok.getLocation()); - ConsumeToken(); - - if(SearchCodeSegmentDeclaration(IITok.getIdentifierInfo()->getName().str())){ - DeclGroupPtrTy ProtoDecl; - ParseTopLevelDecl(ProtoDecl); - // add declaration to AST. - if(ProtoDecl) - (&Actions.getASTConsumer())->HandleTopLevelDecl(ProtoDecl.get()); - // File Closing - Token T; - PP.HandleEndOfFile(T, false); - - // recover tokens. - Tok = SavedToken; - PP.RestoreTokens(CachedTokens, 2); - - } - else { - // recover tokens. - CachedTokens[2] = Tok; - Tok = SavedToken; - PP.RestoreTokens(CachedTokens, 3); - } - - // move to the previous scope. - Actions.CurScope = SavedScope; - Actions.CurContext = SavedContext; - Actions.FunctionScopes.push_back(SavedFSI); - - ProtoParsing = false; - PP.ProtoParsing = false; -} - static bool HasFlagsSet(Parser::SkipUntilFlags L, Parser::SkipUntilFlags R) { return (static_cast(L) & static_cast(R)) != 0; } diff -r a916df8444bf -r 861b2bbafe0a llvm/lib/Passes/PassBuilderPipelines.cpp --- a/llvm/lib/Passes/PassBuilderPipelines.cpp Fri Aug 11 15:57:02 2023 +0900 +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp Fri Aug 11 17:38:36 2023 +0900 @@ -675,7 +675,18 @@ MPM.addPass(PGOInstrumentationGen(IsCS)); #ifndef noCbC + FunctionPassManager FPM; + FPM.addPass(SROAPass()); + FPM.addPass(EarlyCSEPass()); // Catch trivial redundancies. + FPM.addPass(SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp( + true))); // Merge & remove basic blocks. + FPM.addPass(InstCombinePass()); // Combine silly sequences. FPM.addPass(TailCallElimPass()); + invokePeepholeEPCallbacks(FPM, Level); + + // Add the core optimizing pipeline. + MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM), + PTO.EagerlyInvalidateAnalyses)); #endif if (EnablePostPGOLoopRotation) {