<div dir="ltr"><div>This is to enable a feature in the Intel tool OpenCL Code Builder. It is a non-standard option.<br><br></div>Laura<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 12:30 AM, Song, Ruiling <span dir="ltr"><<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 class="HOEnZb"><font color="#888888">Ruiling<br>
</font></span><span class="im HOEnZb">> -----Original Message-----<br>
> From: Beignet [mailto:<a href="mailto:beignet-bounces@lists.freedesktop.org">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">beignet@lists.freedesktop.org</a><br>
> Cc: Ekstrand, Laura D<br>
> Subject: [Beignet] [PATCH] backend/src/backend: Handle -dump-opt-llvm=[PATH]<br>
><br>
</span><div class="HOEnZb"><div class="h5">> 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">Beignet@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/beignet" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a><br>
_______________________________________________<br>
Beignet mailing list<br>
<a href="mailto:Beignet@lists.freedesktop.org">Beignet@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/beignet" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a><br>
</div></div></blockquote></div><br></div>