diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -788,13 +788,20 @@ // Skips a single module summary entry. bool LLParser::SkipModuleSummaryEntry() { // Each module summary entry consists of a tag for the entry - // type, followed by a colon, then the fields surrounded by nested sets of - // parentheses. The "tag:" looks like a Label. Once parsing support is - // in place we will look for the tokens corresponding to the expected tags. + // type, followed by a colon, then the fields which may be surrounded by + // nested sets of parentheses. The "tag:" looks like a Label. Once parsing + // support is in place we will look for the tokens corresponding to the + // expected tags. if (Lex.getKind() != lltok::kw_gv && Lex.getKind() != lltok::kw_module && - Lex.getKind() != lltok::kw_typeid) + Lex.getKind() != lltok::kw_typeid && Lex.getKind() != lltok::kw_flags && + Lex.getKind() != lltok::kw_blockcount) return TokError( - "Expected 'gv', 'module', or 'typeid' at the start of summary entry"); + "Expected 'gv', 'module', 'typeid', 'flags' or 'blockcount' at the " + "start of summary entry"); + if (Lex.getKind() == lltok::kw_flags) + return ParseSummaryIndexFlags(); + if (Lex.getKind() == lltok::kw_blockcount) + return ParseBlockCount(); Lex.Lex(); if (ParseToken(lltok::colon, "expected ':' at start of summary entry") || ParseToken(lltok::lparen, "expected '(' at start of summary entry")) @@ -8169,7 +8176,8 @@ uint64_t Flags; if (ParseUInt64(Flags)) return true; - Index->setFlags(Flags); + if (Index) + Index->setFlags(Flags); return false; } @@ -8184,7 +8192,8 @@ uint64_t BlockCount; if (ParseUInt64(BlockCount)) return true; - Index->setBlockCount(BlockCount); + if (Index) + Index->setBlockCount(BlockCount); return false; } diff --git a/llvm/test/Assembler/thinlto-bad-summary1.ll b/llvm/test/Assembler/thinlto-bad-summary1.ll --- a/llvm/test/Assembler/thinlto-bad-summary1.ll +++ b/llvm/test/Assembler/thinlto-bad-summary1.ll @@ -2,7 +2,7 @@ ; summary type label. ; RUN: not opt %s 2>&1 | FileCheck %s -; CHECK: error: Expected 'gv', 'module', or 'typeid' at the start of summary entry +; CHECK: error: Expected 'gv', 'module', 'typeid', 'flags' or 'blockcount' at the start of summary entry ; ModuleID = 'thinlto-function-summary-callgraph.ll' target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/Assembler/thinlto-blockcount-summary.ll b/llvm/test/Assembler/thinlto-blockcount-summary.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Assembler/thinlto-blockcount-summary.ll @@ -0,0 +1,10 @@ +; Test that we can parse blockcount summaries. +; RUN: opt %s -o /dev/null + +define void @main() { +entry: + ret void +} + +^0 = module: (path: "{{.*}}thinlto-bad-summary5.ll", hash: (0, 0, 0, 0, 0)) +^1 = blockcount: 1234 diff --git a/llvm/test/Assembler/thinlto-flags-summary.ll b/llvm/test/Assembler/thinlto-flags-summary.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Assembler/thinlto-flags-summary.ll @@ -0,0 +1,10 @@ +; Test that we can parse flag summaries. +; RUN: opt %s -o /dev/null + +define void @main() { +entry: + ret void +} + +^0 = module: (path: "{{.*}}thinlto-flags-summary.ll", hash: (0, 0, 0, 0, 0)) +^1 = flags: 8 diff --git a/llvm/test/Assembler/thinlto-summary.ll b/llvm/test/Assembler/thinlto-summary.ll --- a/llvm/test/Assembler/thinlto-summary.ll +++ b/llvm/test/Assembler/thinlto-summary.ll @@ -63,6 +63,8 @@ ; Test the other kinds of type test resoultions ^27 = typeid: (name: "_ZTS1D", summary: (typeTestRes: (kind: byteArray, sizeM1BitWidth: 0))) ^28 = typeid: (name: "_ZTS1E", summary: (typeTestRes: (kind: unsat, sizeM1BitWidth: 0))) +^29 = flags: 8 +^30 = blockcount: 1888 ; Make sure we get back from llvm-dis essentially what we put in via llvm-as. ; CHECK: ^0 = module: (path: "thinlto-summary1.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049)) @@ -94,6 +96,8 @@ ; CHECK: ^26 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi")), (offset: 16, wpdRes: (kind: indir, resByArg: (args: (1, 2), byArg: (kind: indir, byte: 2, bit: 3), args: (3), byArg: (kind: uniformRetVal, info: 1), args: (4), byArg: (kind: uniqueRetVal, info: 1), args: (5), byArg: (kind: virtualConstProp))))))) ; guid = 7004155349499253778 ; CHECK: ^27 = typeid: (name: "_ZTS1D", summary: (typeTestRes: (kind: byteArray, sizeM1BitWidth: 0))) ; guid = 9614786172484273522 ; CHECK: ^28 = typeid: (name: "_ZTS1E", summary: (typeTestRes: (kind: unsat, sizeM1BitWidth: 0))) ; guid = 17437243864166745132 +; CHECK: ^29 = flags: 8 +; CHECK: ^30 = blockcount: 1888 ; Make sure parsing of a non-summary entry containing a ":" does not fail ; after summary parsing, which handles colons differently.