<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">*sigh*<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Eric Christopher [mailto:echristo@gmail.com]
<br>
<b>Sent:</b> Thursday, March 08, 2018 4:06 PM<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> llvm-commits@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm] r327073 - [DWARF] Fix mixing assembler -g with DWARF .file directives.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Still breaking the same testcase:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">echristo@athyra ~/t/debug> cat > foo.c<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">void g() {}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">echristo@athyra ~/t/debug> ~/builds/build-llvm-release-asserts/bin/clang -g foo.c -S -o foo.s<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">echristo@athyra ~/t/debug> ~/builds/build-llvm-release-asserts/bin/clang -g foo.s -c<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">foo.s:8:2: error: file number already allocated<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> .file 1 "foo.c"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> ^<br>
<br>
Can you revert please?<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-eric<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Thu, Mar 8, 2018 at 2:42 PM Paul Robinson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: probinson<br>
Date: Thu Mar 8 14:39:47 2018<br>
New Revision: 327073<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=327073&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=327073&view=rev</a><br>
Log:<br>
[DWARF] Fix mixing assembler -g with DWARF .file directives.<br>
<br>
We were effectively overriding an explicit '.file' directive with info<br>
for the assembler source. That shouldn't happen.<br>
<br>
Fixes PR36636.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D44265" target="_blank">
https://reviews.llvm.org/D44265</a><br>
<br>
Modified:<br>
llvm/trunk/lib/MC/MCParser/AsmParser.cpp<br>
llvm/trunk/test/MC/AsmParser/directive_file-2.s<br>
<br>
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=327073&r1=327072&r2=327073&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=327073&r1=327072&r2=327073&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Mar 8 14:39:47 2018<br>
@@ -311,6 +311,11 @@ private:<br>
}<br>
static void DiagHandler(const SMDiagnostic &Diag, void *Context);<br>
<br>
+ /// Should we emit DWARF describing this assembler source? (Returns false if<br>
+ /// the source has .file directives, which means we don't want to generate<br>
+ /// info describing the assembler source itself.)<br>
+ bool enabledGenDwarfForAssembly();<br>
+<br>
/// \brief Enter the specified file. This returns true on failure.<br>
bool enterIncludeFile(const std::string &Filename);<br>
<br>
@@ -824,6 +829,19 @@ const AsmToken &AsmParser::Lex() {<br>
return *tok;<br>
}<br>
<br>
+bool AsmParser::enabledGenDwarfForAssembly() {<br>
+ // Check whether the user specified -g.<br>
+ if (!getContext().getGenDwarfForAssembly())<br>
+ return false;<br>
+ // If we haven't encountered any .file directives (which would imply that<br>
+ // the assembler source was produced with debug info already) then emit one<br>
+ // describing the assembler source file itself.<br>
+ if (getContext().getGenDwarfFileNumber() == 0)<br>
+ getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective(<br>
+ 0, StringRef(), getContext().getMainFileName()));<br>
+ return true;<br>
+}<br>
+<br>
bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {<br>
// Create the initial section, if requested.<br>
if (!NoInitialTextSection)<br>
@@ -837,7 +855,9 @@ bool AsmParser::Run(bool NoInitialTextSe<br>
SmallVector<AsmRewrite, 4> AsmStrRewrites;<br>
<br>
// If we are generating dwarf for assembly source files save the initial text<br>
- // section and generate a .file directive.<br>
+ // section. (Don't use enabledGenDwarfForAssembly() here, as we aren't<br>
+ // emitting any actual debug info yet and haven't had a chance to parse any<br>
+ // embedded .file directives.)<br>
if (getContext().getGenDwarfForAssembly()) {<br>
MCSection *Sec = getStreamer().getCurrentSectionOnly();<br>
if (!Sec->getBeginSymbol()) {<br>
@@ -848,8 +868,6 @@ bool AsmParser::Run(bool NoInitialTextSe<br>
bool InsertResult = getContext().addGenDwarfSection(Sec);<br>
assert(InsertResult && ".text section should not have debug info yet");<br>
(void)InsertResult;<br>
- getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective(<br>
- 0, StringRef(), getContext().getMainFileName()));<br>
}<br>
<br>
// While we have input, parse each statement.<br>
@@ -1784,7 +1802,7 @@ bool AsmParser::parseStatement(ParseStat<br>
<br>
// If we are generating dwarf for assembly source files then gather the<br>
// info to make a dwarf label entry for this label if needed.<br>
- if (getContext().getGenDwarfForAssembly())<br>
+ if (enabledGenDwarfForAssembly())<br>
MCGenDwarfLabelEntry::Make(Sym, &getStreamer(), getSourceManager(),<br>
IDLoc);<br>
<br>
@@ -2153,7 +2171,7 @@ bool AsmParser::parseStatement(ParseStat<br>
<br>
// If we are generating dwarf for the current section then generate a .loc<br>
// directive for the instruction.<br>
- if (!ParseHadError && getContext().getGenDwarfForAssembly() &&<br>
+ if (!ParseHadError && enabledGenDwarfForAssembly() &&<br>
getContext().getGenDwarfSectionSyms().count(<br>
getStreamer().getCurrentSectionOnly())) {<br>
unsigned Line;<br>
@@ -3336,15 +3354,12 @@ bool AsmParser::parseDirectiveFile(SMLoc<br>
}<br>
// If there is -g option as well as debug info from directive file,<br>
// we turn off -g option, directly use the existing debug info instead.<br>
- if (getContext().getGenDwarfForAssembly())<br>
- getContext().setGenDwarfForAssembly(false);<br>
- else {<br>
- Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective(<br>
- FileNumber, Directory, Filename, CKMem, Source);<br>
- if (!FileNumOrErr)<br>
- return Error(DirectiveLoc, toString(FileNumOrErr.takeError()));<br>
- FileNumber = FileNumOrErr.get();<br>
- }<br>
+ getContext().setGenDwarfForAssembly(false);<br>
+ Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective(<br>
+ FileNumber, Directory, Filename, CKMem, Source);<br>
+ if (!FileNumOrErr)<br>
+ return Error(DirectiveLoc, toString(FileNumOrErr.takeError()));<br>
+ FileNumber = FileNumOrErr.get();<br>
}<br>
<br>
return false;<br>
<br>
Modified: llvm/trunk/test/MC/AsmParser/directive_file-2.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_file-2.s?rev=327073&r1=327072&r2=327073&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_file-2.s?rev=327073&r1=327072&r2=327073&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/AsmParser/directive_file-2.s (original)<br>
+++ llvm/trunk/test/MC/AsmParser/directive_file-2.s Thu Mar 8 14:39:47 2018<br>
@@ -1,4 +1,4 @@<br>
-// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s<br>
+// RUN: llvm-mc -g -triple i386-unknown-unknown %s | FileCheck %s<br>
// Test for Bug 11740<br>
// This testcase has two directive files,<br>
// when compiled with -g, this testcase will not report error,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>