[LLVMdev] Pass Ordering
criswell at illinois.edu
Fri Aug 13 11:15:46 PDT 2010
aparna kotha wrote:
> I have a ModulePass (A) calling a FunctionPass that inturn calls
> TargetData (a ModulePass). For reasons of code correctness and
> modularity I cannot reorganize my passes in any other way .
> When I use opt to load and run A , it gives the following error.
> LLVM ERROR: Bad TargetData ctor used. Tool did not specify a
> TargetData to use?
> I gather from some previous emails that this was not supported. Is it
> still not supported? and is there any way I can avoid this.
For some reason, the TargetData pass must use a special constructor
method that gives it a reference to the module to be analyzed. This
means that declaring it as a dependency in your getAnalysisUsage()
methods isn't enough; whatever program is adding your passes to the
PassManager must add TargetData explicitly as one of the passes to run.
The opt program does this automatically, so I'm assuming you're writing
your own tool that creates a PassManager and tells it to run some
passes. You want to add code like the following to your tool:
PassManager Passes; // This line probably exists in your code already
// Explicitly schedule the TargetData pass as the first pass to run;
note that M.get() gets a pointer or reference
// to the module to analyze
-- John T.
> Thanks and Regards
> Aparna Kotha
> Graduate Student
> University of Maryland, College Park
More information about the llvm-dev