-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grammar: add module summary (introduced in LLVM 7.0) #43
Comments
I'll mark this for a later release. I have yet to find an LLVM IR file containing ThinLTO module summary information outside of the test case suite. |
Also adding the help wanted tag, should anyone feel like taking a stab at implementing this :) |
The 8.0 release of LLVM introduced the notion of As of current, the LLVM IR grammar in llir/ll does not have support for global variables summaries. Any help with updating the grammar to add support for this would be warmly appreciated. To the brave soul who is up for this challenge, I can recommend downloading the source release of LLVM for version 7.0 and 8.0 and running $ diff -r -u llvm-7.0.0.src/lib/AsmParser/ llvm-8.0.0.src/lib/AsmParser/ +++ llvm-8.0.0.src/lib/AsmParser/LLParser.cpp 2019-10-24 23:46:14.584517952 +0200
+/// GVarFlags
+/// ::= 'varFlags' ':' '(' 'readonly' ':' Flag ')'
+bool LLParser::ParseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags) {
+ assert(Lex.getKind() == lltok::kw_varFlags);
+ Lex.Lex();
+
+ unsigned Flag;
+ if (ParseToken(lltok::colon, "expected ':' here") ||
+ ParseToken(lltok::lparen, "expected '(' here") ||
+ ParseToken(lltok::kw_readonly, "expected 'readonly' here") ||
+ ParseToken(lltok::colon, "expected ':' here"))
+ return true;
+
+ ParseFlag(Flag);
+ GVarFlags.ReadOnly = Flag;
+
+ if (ParseToken(lltok::rparen, "expected ')' here"))
+ return true;
+ return false;
+}
+ |
For anyone interested in implementing support for module summaries, take a look In particular, the following functions are relevant:
Grammar extracted from comments: /// ParseGVEntry
/// ::= 'gv' ':' '(' ('name' ':' STRINGCONSTANT | 'guid' ':' UInt64)
/// [',' 'summaries' ':' Summary[',' Summary]* ]? ')'
/// Summary ::= '(' (FunctionSummary | VariableSummary | AliasSummary) ')'
/// FunctionSummary
/// ::= 'function' ':' '(' 'module' ':' ModuleReference ',' GVFlags
/// ',' 'insts' ':' UInt32 [',' OptionalFFlags]? [',' OptionalCalls]?
/// [',' OptionalTypeIdInfo]? [',' OptionalRefs]? ')'
/// VariableSummary
/// ::= 'variable' ':' '(' 'module' ':' ModuleReference ',' GVFlags
/// [',' OptionalRefs]? ')'
/// AliasSummary
/// ::= 'alias' ':' '(' 'module' ':' ModuleReference ',' GVFlags ','
/// 'aliasee' ':' GVReference ')'
/// OptionalVTableFuncs
/// := 'vTableFuncs' ':' '(' VTableFunc [',' VTableFunc]* ')'
/// VTableFunc ::= '(' 'virtFunc' ':' GVReference ',' 'offset' ':' UInt64 ')'
/// OptionalRefs
/// := 'refs' ':' '(' GVReference [',' GVReference]* ')'
/// OptionalTypeIdInfo
/// := 'typeidinfo' ':' '(' [',' TypeTests]? [',' TypeTestAssumeVCalls]?
/// [',' TypeCheckedLoadVCalls]? [',' TypeTestAssumeConstVCalls]?
/// [',' TypeCheckedLoadConstVCalls]? ')'
/// TypeTests
/// ::= 'typeTests' ':' '(' (SummaryID | UInt64)
/// [',' (SummaryID | UInt64)]* ')'
/// VFuncIdList
/// ::= Kind ':' '(' VFuncId [',' VFuncId]* ')'
/// ConstVCallList
/// ::= Kind ':' '(' ConstVCall [',' ConstVCall]* ')'
/// ConstVCall
/// ::= '(' VFuncId ',' Args ')'
/// GVFlags
/// ::= 'flags' ':' '(' 'linkage' ':' OptionalLinkageAux ','
/// 'notEligibleToImport' ':' Flag ',' 'live' ':' Flag ','
/// 'dsoLocal' ':' Flag ',' 'canAutoHide' ':' Flag ')'
/// GVarFlags
/// ::= 'varFlags' ':' '(' 'readonly' ':' Flag
/// ',' 'writeonly' ':' Flag ')'
/// ModuleReference
/// ::= 'module' ':' UInt
/// GVReference
/// ::= SummaryID |
Relevant test cases from #111 (comment) Grammar related to Module Summarytest cases failing related to Module Summary grammar
|
Also, remove Module Summary diffs (tracked by #43).
Also, remove Module Summary diffs (tracked by #43).
In LLVM 7.0 the concept of ThinLTO module summaries was introduced. We currently have no IR representation of module summaries, and the grammar for module summaries has not yet been written.
A test case containing a module summary is present in llvm/test/Assembler/thinlto-summary.ll:
The text was updated successfully, but these errors were encountered: