[LLVMdev] Pass is not automatically registered
Morten Ofstad
morten at hue.no
Mon Sep 5 05:42:03 PDT 2005
If you are using Visual Studio, the linker will throw away object files which have no external references to them --
even if the object file contains static objects with constructors which might (or in the case of LLVM passes, definitly)
have side effects. The solution is to use the linker option to force symbol references to a symbol in the object file so
it doesn't throw it away. This problem is the motivation for having the _X86TargetMachineModule symbol in LLVM.
m.
Tzu-Chien Chiu wrote:
> I am not sure if my problem is similar to:
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2003-December/000715.html
>
> It seems that the constructor of the static global pass object isn't called:
>
> lib/CodeGen/DependenceAnalyzer.cpp:
>
> static RegisterAnalysis<DependenceAnalyzer> X("depana", "Dependence Analysis");
>
> I traced into struct RegisterAnalysis ctor, but my pass doesn't
> appear. I put it in an anonymous namespace, it doesn't work too.
>
>
> The class definitions:
>
> class DependenceAnalyzer : public MachineFunctionPass {
> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.setPreservesAll();
> AU.addRequired<LiveIntervals>();
> AU.addRequired<LiveVariables>();
> MachineFunctionPass::getAnalysisUsage(AU);
> }
>
> class RegAllocMultibank : public MachineFunctionPass {
> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
> AU.addRequired<LiveIntervals>();
> AU.addRequired<DependenceAnalyzer>();
> MachineFunctionPass::getAnalysisUsage(AU);
> }
> };
>
More information about the llvm-dev
mailing list