I am using opt , so i cm confused if i need to do this. On the other hand I modified my functionPass not to call TargetData , and I still get this error. My functionPass still calls Alias Analysis though. <div><br></div><div>
<br></div><div><br></div><div>Aparna <br><br><div class="gmail_quote">On Fri, Aug 13, 2010 at 2:15 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">aparna kotha wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
All, <br>
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 . <br>
When I use opt to load and run A , it gives the following error. <br>
LLVM ERROR: Bad TargetData ctor used.  Tool did not specify a TargetData to use?<br>
<br>
<br>
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.<br>
</blockquote>
<br></div>
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.<br>

<br>
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:<br>
<br>
PassManager Passes;   // This line probably exists in your code already<br>
<br>
// Explicitly schedule the TargetData pass as the first pass to run; note that M.get() gets a pointer or reference<br>
// to the module to analyze<br>
Passes.add(new TargetData(M.get()));<br>
<br>
-- John T.<div><div></div><div class="h5"><br>
<br>
<br>
 <br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
<br>
Thanks and Regards<br>
<br>
<br>
Aparna Kotha <br>
Graduate Student University of Maryland, College Park <br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>