<div dir="ltr">Hi,<br><div><br>It seems to me that the CompilerEngine is not reentrant, either by design or by mistake (the latter seems more likely).<br><br></div><div>I think that a reset of the count is missing from the initialization when you call compileCode(), and thus the second time it (incorrectly) diagnose that you are trying to pass the option a second time, not realizing it is a different run.<br>
<br></div><div>-- Matthieu<br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 19, 2013 at 8:01 PM, Alan Garny <span dir="ltr"><<a href="mailto:agarny@hellix.com" target="_blank">agarny@hellix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-GB"><div><p class="MsoNormal"><span lang="EN-US">Hi,<u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">My application generates some C code which I then compile using LLVM+Clang before running it. For the compilation side of things, I have a class which one of the methods (the </span>CompilerEngine::compileCode() method in <a href="https://raw.github.com/opencor/opencor/llvm_3.3/src/plugins/misc/Compiler/src/compilerengine.cpp" target="_blank">https://raw.github.com/opencor/opencor/llvm_3.3/src/plugins/misc/Compiler/src/compilerengine.cpp</a>) is based on the code from the <span lang="EN-US">clang-interpreter example (</span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?view=co" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?view=co</a>). The idea is therefore to create an instance of the ‘compiler’ class and, among other things, use its compileCode() whenever needed.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">All of this works perfectly fine using LLVM+Clang 3.2, but not with LLVM+Clang 3.3. At least, not out of the box. Basically, the first time I try to compile some C code, everything is fine. However, if I try to compile some other C code, then I will get the following error message:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="text-indent:36.0pt"><span lang="EN-US">clang: for the -vectorize-loops option: may only occur zero or one times! <u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">FWIW, I use the -O3 option which I understand makes implicit use of the loop vectorizer, and that seems to be the problem. Indeed, if I disable the loop vectorizer (using the -fno-vectorize option), then everything is fine but I clearly don’t want to have to do that. So, right now, my solution consists of commenting out the test for the number of option occurrences in the Option::addOccurrence() method (<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?view=co" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?view=co</a>), but it is clearly not satisfactory either (even though it’s good enough for my particular purpose).<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">So, would anyone have any idea about what I might be missing, if anything?... <u></u><u></u></span></p><p class="MsoNormal">
<span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Cheers, Alan.<u></u><u></u></span></p></div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>