[cfe-dev] LLVM+Clang 3.3: clang: for the -vectorize-loops option: may only occur zero or one times!
Alan Garny
agarny at hellix.com
Thu Jun 20 09:51:25 PDT 2013
Hi Matthieu,
You are correct in that CompilerEngine is not re-entrant, and it's actually
by design. The idea is to create an instance of CompilerEngine, compile some
code with it, and then use the compiled code. From there, once you are done
with that code and don't need it anymore, you can compile some other code.
So, in the current use of CompilerEngine, there cannot be a case where a
call to compileCode() is made while another call to compileCode() is still
being performed. If you ever wanted to do that, then you would create two
instances of CompilerEngine.
Anyway, I don't think the problem lies with CompilerEngine. As I mentioned
in my original message, everything works fine with LLVM+Clang 3.2. It seems
like LLVM keeps track of command line options (through
llvm::cl::RegisteredOptionList) and this is what is causing me problems. So,
I am now wondering whether there is a way to 'reset' LLVM so that I can
'properly' call clang more than once?
Alan
From: Matthieu Monrocq [mailto:matthieu.monrocq at gmail.com]
Sent: 20 June 2013 18:35
To: Alan Garny
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] LLVM+Clang 3.3: clang: for the -vectorize-loops
option: may only occur zero or one times!
Hi,
It seems to me that the CompilerEngine is not reentrant, either by design or
by mistake (the latter seems more likely).
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.
-- Matthieu
On Wed, Jun 19, 2013 at 8:01 PM, Alan Garny <agarny at hellix.com> wrote:
Hi,
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 CompilerEngine::compileCode() method in
https://raw.github.com/opencor/opencor/llvm_3.3/src/plugins/misc/Compiler/sr
c/compilerengine.cpp) is based on the code from the clang-interpreter
example
(http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/ma
in.cpp?view=co). The idea is therefore to create an instance of the
'compiler' class and, among other things, use its compileCode() whenever
needed.
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:
clang: for the -vectorize-loops option: may only occur zero or one times!
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
(http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?
view=co), but it is clearly not satisfactory either (even though it's good
enough for my particular purpose).
So, would anyone have any idea about what I might be missing, if
anything?...
Cheers, Alan.
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130620/18ec596e/attachment.html>
More information about the cfe-dev
mailing list