[cfe-dev] Analysis and code generation actions
Anton.Lokhmotov at arm.com
Thu Feb 11 09:20:13 PST 2010
Dear Clang aficionados,
I'd like to adapt Clang to accept a C extension, perform a bit of analysis
and then output LLVM IR.
First, I learnt how to use Sema/ParseAST and CodeGen/ModuleBuilder in the
2.6 release. However, since ParseAST in not re-enterable I can't do analysis
and code generation at the same time. So I'd really appreciate if you could
point me to the right way of doing this!
Second, I'm looking to the development branch. I see some great looking API
changes, such as introducing CompilerInstance and CompilerInvocation, and a
bunch of FrontendActions. I was hoping to use FrontendActions for
implementing my analysis and code gen, but no luck so far.
The minimal program
/// \file CompilerInstance.c
lib/VMCore/Pass.cpp:228: void <unnamed>::PassRegistrar::RegisterPass(const
llvm::PassInfo&): Assertion `Inserted && "Pass registered multiple times!"'
In addition, by trial and error I figured out that I needed to link against
many Clang and LLVM libraries, e.g.
g++ ./CompilerInstance.o -lclangFrontend -lclangSema -lclangDriver
-lclangAnalysis -lclangChecker -lclangRewrite -lclangAST -lclangCodeGen
-lclangLex -lclangBasic -lclangParse -lLLVMScalarOpts -lLLVMInstCombine
-lLLVMSelectionDAG -lLLVMipo -lLLVMipa -lLTO -lLLVMTransformUtils
-lLLVMBitWriter -lLLVMAnalysis -lLLVMCodeGen -lLLVMCore -lLLVMMC
-lLLVMSupport -lLLVMSystem -lLLVMTarget -lm -ldl -lpthread
I find it weird that in order to use a FrontendAction that only emits LLVM
code I also need to link against so many optimisation libraries. Can I
conclude from this experience that FrontendActions are not supposed to be
used like this? (The same happens when I first initialise a CompilerInstance
properly and then declare an EmitLLVMOnlyAction object.) Again, what would
be the right way to do this?
I'd really appreciate your help and hope to become part of the developer
P.S. I'm almost as desperate as Devin Townsend's Ziltoid:
[Narrator:] Having been rejected by the Planet smasher, Ziltoid seeks the
council of the Omnidimensional Creator.
[Ziltoid:] Assuage my confusion about creation and the universe!
[Creator:] Yo! Ziltoid, what's up dude?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev