<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 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 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">Hi Ruiling,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Yes like Laura mentioned I would be taking over for Laura. I have looked at the patch and made the recommended changes to add support for LLVM 3.6. I am working
 on testing it on my end and will send the patch for review after that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Manasi<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>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Laura Ekstrand [mailto:laura@jlekstrand.net]
<br>
<b>Sent:</b> Thursday, July 30, 2015 6:36 PM<br>
<b>To:</b> Song, Ruiling<br>
<b>Cc:</b> Ekstrand, Laura D; beignet@lists.freedesktop.org; Navare, Manasi D<br>
<b>Subject:</b> Re: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hello Ruiling,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Manasi will be taking over this patch for me.  Thanks for your review!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Laura<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Jul 29, 2015 at 12:19 AM, Song, Ruiling <<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Laura,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I see! Thanks for the info.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The patch basically looks good, but it does not work under llvm 3.6.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Llvm 3.6 change the raw_fd_ostream constructor.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It is defined as: raw_fd_ostream( StringRef fileName, std::error_code &EC, sys::fs::OpenFlags Flags)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">So, you need to add some logic like below to handle this:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">        std::string err;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">                                      err, llvm::sys::fs::F_RW);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">        if (err.empty()) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">          out_module->print(ostream, 0);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">        } //Otherwise, you'll have to make do without the dump.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#else</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">      std::error_code err;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">      llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">                                    err, llvm::sys::fs::F_RW);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">      if (!err) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">        out_module->print(ostream, 0);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">      }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#endif</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="14ed8b0975bd5ad0__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span></a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Other parts of the patch LGTM. So could you fix it and send a new version?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">And also please include “Signed-off-by: ” in your patch.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks!</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Ruiling</span><o:p></o:p></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 #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org" target="_blank">beignet-bounces@lists.freedesktop.org</a>]
<b>On Behalf Of </b>Laura Ekstrand<br>
<b>Sent:</b> Wednesday, July 29, 2015 5:03 AM<br>
<b>To:</b> Song, Ruiling<br>
<b>Cc:</b> Ekstrand, Laura D; <a href="mailto:beignet@lists.freedesktop.org" target="_blank">
beignet@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]</span><o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">This is to enable a feature in the Intel tool OpenCL Code Builder.  It is a non-standard option.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Laura<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Tue, Jul 28, 2015 at 12:30 AM, Song, Ruiling <<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Could you explain why this is needed?<br>
And is "dump-opt-llvm" a llvm-standard option or opencl option?<br>
<br>
Thanks!<br>
<span style="color:#888888">Ruiling<br>
</span>> -----Original Message-----<br>
> From: Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org" target="_blank">beignet-bounces@lists.freedesktop.org</a>] On Behalf Of<br>
> Laura Ekstrand<br>
> Sent: Friday, July 10, 2015 3:04 AM<br>
> To: <a href="mailto:beignet@lists.freedesktop.org" target="_blank">beignet@lists.freedesktop.org</a><br>
> Cc: Ekstrand, Laura D<br>
> Subject: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]<br>
><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> Allows the user to request a dump of the LLVM-generated IR to the file specified<br>
> in [PATH].<br>
> ---<br>
>  backend/src/backend/program.cpp | 26 +++++++++++++++++++++++---<br>
>  1 file changed, 23 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/backend/src/backend/program.cpp<br>
> b/backend/src/backend/program.cpp index e4cdeaa..b55f75a 100644<br>
> --- a/backend/src/backend/program.cpp<br>
> +++ b/backend/src/backend/program.cpp<br>
> @@ -640,6 +640,7 @@ namespace gbe {<br>
>                                       const char *options,<br>
>                                       const char *temp_header_path,<br>
>                                       std::vector<std::string>& clOpt,<br>
> +                                     std::string& dumpLLVMFileName,<br>
>                                       std::string& clName,<br>
>                                       int& optLevel,<br>
>                                       size_t stringSize, @@ -719,6 +720,11 @@ namespace gbe {<br>
>            clOpt.push_back("__FAST_RELAXED_MATH__=1");<br>
>          }<br>
><br>
> +        if(str.find("-dump-opt-llvm=") != std::string::npos) {<br>
> +          dumpLLVMFileName = str.substr(str.find("=") + 1);<br>
> +          continue; // Don't push this str back; ignore it.<br>
> +        }<br>
> +<br>
>          clOpt.push_back(str);<br>
>        }<br>
>        free(str);<br>
> @@ -781,8 +787,10 @@ namespace gbe {<br>
>      int optLevel = 1;<br>
>      std::vector<std::string> clOpt;<br>
>      std::string clName;<br>
> -    if (!processSourceAndOption(source, options, NULL, clOpt, clName,<br>
> -                                optLevel, stringSize, err, errSize))<br>
> +    std::string dumpLLVMFileName;<br>
> +    if (!processSourceAndOption(source, options, NULL, clOpt,<br>
> +                                dumpLLVMFileName, clName, optLevel,<br>
> +                                stringSize, err, errSize))<br>
>        return NULL;<br>
><br>
>      gbe_program p;<br>
> @@ -804,6 +812,16 @@ namespace gbe {<br>
>          clangErrSize = *errSize;<br>
>        }<br>
><br>
> +      // Dump the LLVM if requested.<br>
> +      if (!dumpLLVMFileName.empty()) {<br>
> +        std::string err;<br>
> +        llvm::raw_fd_ostream ostream (dumpLLVMFileName.c_str(),<br>
> +                                      err, llvm::sys::fs::F_RW);<br>
> +        if (err.empty()) {<br>
> +          out_module->print(ostream, 0);<br>
> +        } //Otherwise, you'll have to make do without the dump.<br>
> +      }<br>
> +<br>
>        p = gbe_program_new_from_llvm(deviceID, NULL, out_module, llvm_ctx,<br>
> stringSize,<br>
>                                      err, errSize, optLevel);<br>
>        if (err != NULL)<br>
> @@ -834,7 +852,9 @@ namespace gbe {<br>
>      int optLevel = 1;<br>
>      std::vector<std::string> clOpt;<br>
>      std::string clName;<br>
> -    if (!processSourceAndOption(source, options, temp_header_path, clOpt,<br>
> clName,<br>
> +    std::string dumpLLVMFileName;<br>
> +    if (!processSourceAndOption(source, options, temp_header_path, clOpt,<br>
> +                                dumpLLVMFileName, clName,<br>
>                                  optLevel, stringSize, err, errSize))<br>
>        return NULL;<br>
><br>
> --<br>
> 2.1.0<br>
><br>
> _______________________________________________<br>
> Beignet mailing list<br>
> <a href="mailto:Beignet@lists.freedesktop.org" target="_blank">Beignet@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">
http://lists.freedesktop.org/mailman/listinfo/beignet</a><br>
_______________________________________________<br>
Beignet mailing list<br>
<a href="mailto:Beignet@lists.freedesktop.org" target="_blank">Beignet@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>