diff options
| author | Teresa Johnson <tejohnson@google.com> | 2016-03-30 14:00:02 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2016-03-30 14:00:02 +0000 |
| commit | 832a6790f66c5ec637b3be95703fedf520a38b33 (patch) | |
| tree | fa2da029e58192817d152763bfc73bcb95fb63f3 /llvm/lib | |
| parent | 0c7bb965336d458a2582cc8542d43bec1330430d (diff) | |
| download | bcm5719-llvm-832a6790f66c5ec637b3be95703fedf520a38b33.tar.gz bcm5719-llvm-832a6790f66c5ec637b3be95703fedf520a38b33.zip | |
[ThinLTO] Serialize the Module SourceFileName to/from LLVM assembly
Summary:
This change serializes out and in the SourceFileName to LLVM assembly
so that it is preserved through "llvm-dis | llvm-as". This is
necessary to ensure that the global identifiers created for local values
in the module summary index are the same even if the bitcode is
streamed out and read back from LLVM assembly.
Serializing the summary itself to LLVM assembly is in progress.
Reviewers: joker.eph
Subscribers: llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D18588
llvm-svn: 264869
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 17 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 1 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 1 | ||||
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 3 |
5 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index d2385130912..46ffc642ec6 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -533,6 +533,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(notail); KEYWORD(target); KEYWORD(triple); + KEYWORD(source_filename); KEYWORD(unwind); KEYWORD(deplibs); // FIXME: Remove in 4.0. KEYWORD(datalayout); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 76bd99e9b66..39c613599e6 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -239,6 +239,10 @@ bool LLParser::ParseTopLevelEntities() { case lltok::kw_define: if (ParseDefine()) return true; break; case lltok::kw_module: if (ParseModuleAsm()) return true; break; case lltok::kw_target: if (ParseTargetDefinition()) return true; break; + case lltok::kw_source_filename: + if (ParseSourceFileName()) + return true; + break; case lltok::kw_deplibs: if (ParseDepLibs()) return true; break; case lltok::LocalVarID: if (ParseUnnamedType()) return true; break; case lltok::LocalVar: if (ParseNamedType()) return true; break; @@ -336,6 +340,19 @@ bool LLParser::ParseTargetDefinition() { } /// toplevelentity +/// ::= 'source_filename' '=' STRINGCONSTANT +bool LLParser::ParseSourceFileName() { + assert(Lex.getKind() == lltok::kw_source_filename); + std::string Str; + Lex.Lex(); + if (ParseToken(lltok::equal, "expected '=' after source_filename") || + ParseStringConstant(Str)) + return true; + M->setSourceFileName(Str); + return false; +} + +/// toplevelentity /// ::= 'deplibs' '=' '[' ']' /// ::= 'deplibs' '=' '[' STRINGCONSTANT (',' STRINGCONSTANT)* ']' /// FIXME: Remove in 4.0. Currently parse, but ignore. diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index 96f864a7f1a..fcece62c6b8 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -261,6 +261,7 @@ namespace llvm { bool ValidateEndOfModule(); bool ParseTargetDefinition(); bool ParseModuleAsm(); + bool ParseSourceFileName(); bool ParseDepLibs(); // FIXME: Remove in 4.0. bool ParseUnnamedType(); bool ParseNamedType(); diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index f06b5b81a13..c5a74901985 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -59,6 +59,7 @@ namespace lltok { kw_notail, kw_target, kw_triple, + kw_source_filename, kw_unwind, kw_deplibs, // FIXME: Remove in 4.0 kw_datalayout, diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index ab56f08014e..3051193f890 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2215,6 +2215,9 @@ void AssemblyWriter::printModule(const Module *M) { M->getModuleIdentifier().find('\n') == std::string::npos) Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n"; + if (!M->getSourceFileName().empty()) + Out << "source_filename = \"" << M->getSourceFileName() << "\"\n"; + const std::string &DL = M->getDataLayoutStr(); if (!DL.empty()) Out << "target datalayout = \"" << DL << "\"\n"; |

