<div dir="ltr">Changes to the textual IR require updating the language reference located in docs/LangRef.rst; I started seeing this in my IR and had very little idea as to why.<div><br></div><div>Also, couldn't this just be module-level metadata?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 30, 2016 at 7:00 AM, Teresa Johnson via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tejohnson<br>
Date: Wed Mar 30 09:00:02 2016<br>
New Revision: 264869<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264869&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264869&view=rev</a><br>
Log:<br>
[ThinLTO] Serialize the Module SourceFileName to/from LLVM assembly<br>
<br>
Summary:<br>
This change serializes out and in the SourceFileName to LLVM assembly<br>
so that it is preserved through "llvm-dis | llvm-as". This is<br>
necessary to ensure that the global identifiers created for local values<br>
in the module summary index are the same even if the bitcode is<br>
streamed out and read back from LLVM assembly.<br>
<br>
Serializing the summary itself to LLVM assembly is in progress.<br>
<br>
Reviewers: joker.eph<br>
<br>
Subscribers: llvm-commits, joker.eph<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D18588" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18588</a><br>
<br>
Added:<br>
llvm/trunk/test/Assembler/source-filename.ll<br>
Modified:<br>
llvm/trunk/lib/AsmParser/LLLexer.cpp<br>
llvm/trunk/lib/AsmParser/LLParser.cpp<br>
llvm/trunk/lib/AsmParser/LLParser.h<br>
llvm/trunk/lib/AsmParser/LLToken.h<br>
llvm/trunk/lib/IR/AsmWriter.cpp<br>
<br>
Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=264869&r1=264868&r2=264869&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=264869&r1=264868&r2=264869&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)<br>
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Wed Mar 30 09:00:02 2016<br>
@@ -533,6 +533,7 @@ lltok::Kind LLLexer::LexIdentifier() {<br>
KEYWORD(notail);<br>
KEYWORD(target);<br>
KEYWORD(triple);<br>
+ KEYWORD(source_filename);<br>
KEYWORD(unwind);<br>
KEYWORD(deplibs); // FIXME: Remove in 4.0.<br>
KEYWORD(datalayout);<br>
<br>
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=264869&r1=264868&r2=264869&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=264869&r1=264868&r2=264869&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)<br>
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Mar 30 09:00:02 2016<br>
@@ -239,6 +239,10 @@ bool LLParser::ParseTopLevelEntities() {<br>
case lltok::kw_define: if (ParseDefine()) return true; break;<br>
case lltok::kw_module: if (ParseModuleAsm()) return true; break;<br>
case lltok::kw_target: if (ParseTargetDefinition()) return true; break;<br>
+ case lltok::kw_source_filename:<br>
+ if (ParseSourceFileName())<br>
+ return true;<br>
+ break;<br>
case lltok::kw_deplibs: if (ParseDepLibs()) return true; break;<br>
case lltok::LocalVarID: if (ParseUnnamedType()) return true; break;<br>
case lltok::LocalVar: if (ParseNamedType()) return true; break;<br>
@@ -336,6 +340,19 @@ bool LLParser::ParseTargetDefinition() {<br>
}<br>
<br>
/// toplevelentity<br>
+/// ::= 'source_filename' '=' STRINGCONSTANT<br>
+bool LLParser::ParseSourceFileName() {<br>
+ assert(Lex.getKind() == lltok::kw_source_filename);<br>
+ std::string Str;<br>
+ Lex.Lex();<br>
+ if (ParseToken(lltok::equal, "expected '=' after source_filename") ||<br>
+ ParseStringConstant(Str))<br>
+ return true;<br>
+ M->setSourceFileName(Str);<br>
+ return false;<br>
+}<br>
+<br>
+/// toplevelentity<br>
/// ::= 'deplibs' '=' '[' ']'<br>
/// ::= 'deplibs' '=' '[' STRINGCONSTANT (',' STRINGCONSTANT)* ']'<br>
/// FIXME: Remove in 4.0. Currently parse, but ignore.<br>
<br>
Modified: llvm/trunk/lib/AsmParser/LLParser.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=264869&r1=264868&r2=264869&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=264869&r1=264868&r2=264869&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/AsmParser/LLParser.h (original)<br>
+++ llvm/trunk/lib/AsmParser/LLParser.h Wed Mar 30 09:00:02 2016<br>
@@ -261,6 +261,7 @@ namespace llvm {<br>
bool ValidateEndOfModule();<br>
bool ParseTargetDefinition();<br>
bool ParseModuleAsm();<br>
+ bool ParseSourceFileName();<br>
bool ParseDepLibs(); // FIXME: Remove in 4.0.<br>
bool ParseUnnamedType();<br>
bool ParseNamedType();<br>
<br>
Modified: llvm/trunk/lib/AsmParser/LLToken.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=264869&r1=264868&r2=264869&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=264869&r1=264868&r2=264869&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/AsmParser/LLToken.h (original)<br>
+++ llvm/trunk/lib/AsmParser/LLToken.h Wed Mar 30 09:00:02 2016<br>
@@ -59,6 +59,7 @@ namespace lltok {<br>
kw_notail,<br>
kw_target,<br>
kw_triple,<br>
+ kw_source_filename,<br>
kw_unwind,<br>
kw_deplibs, // FIXME: Remove in 4.0<br>
kw_datalayout,<br>
<br>
Modified: llvm/trunk/lib/IR/AsmWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=264869&r1=264868&r2=264869&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=264869&r1=264868&r2=264869&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)<br>
+++ llvm/trunk/lib/IR/AsmWriter.cpp Wed Mar 30 09:00:02 2016<br>
@@ -2215,6 +2215,9 @@ void AssemblyWriter::printModule(const M<br>
M->getModuleIdentifier().find('\n') == std::string::npos)<br>
Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n";<br>
<br>
+ if (!M->getSourceFileName().empty())<br>
+ Out << "source_filename = \"" << M->getSourceFileName() << "\"\n";<br>
+<br>
const std::string &DL = M->getDataLayoutStr();<br>
if (!DL.empty())<br>
Out << "target datalayout = \"" << DL << "\"\n";<br>
<br>
Added: llvm/trunk/test/Assembler/source-filename.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/source-filename.ll?rev=264869&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/source-filename.ll?rev=264869&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Assembler/source-filename.ll (added)<br>
+++ llvm/trunk/test/Assembler/source-filename.ll Wed Mar 30 09:00:02 2016<br>
@@ -0,0 +1,8 @@<br>
+<br>
+; Make sure that llvm-as/llvm-dis properly assemble/disassemble the<br>
+; source_filename.<br>
+<br>
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s<br>
+<br>
+; CHECK: source_filename = "test.cc"<br>
+source_filename = "test.cc"<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>