[LLVMdev] addPassesToEmit(Whole)File changes?

Marcel Weiher marcel at metaobject.com
Sun Jan 21 23:40:04 PST 2007


On Jan 21, 2007, at 20:41 , Chris Lattner wrote:
> On Sun, 21 Jan 2007, Marcel Weiher wrote:
>> [troubles with 1.9 changes]
>
> Right, you want to use addPassesToEmitFile if you want the native code
> generators to work.

Ahh...thanks for the quick response!  Sad that the nice high-level  
functionality is gone and I now have to do it manually.

> The proper incantations can be found in tools/llc/llc.cpp.

OK, I guess I should look more at the tools.  Had been looking mostly  
at the examples, but those only take you so far.

> You should do something like this:
>
>        // Build up all of the passes that we want to do to the module.
>        FunctionPassManager Passes(new  
> ExistingModuleProvider(M.get()));
>        Passes.add(new TargetData(*Target.getTargetData()));
>
>        // Ask the target to add backend passes as necessary.
>        if (Target.addPassesToEmitFile(Passes, *Out, FileType, Fast)) {
>          std::cerr << argv[0] << ": target does not support  
> generation of this"
>                    << " file type!\n";
>          if (Out != &std::cout) delete Out;
>          // And the Out file is empty and useless, so remove it now.
>          sys::Path(OutputFilename).eraseFromDisk();
>          return 1;
>        }
>
>        Passes.doInitialization();
>
>        // Run our queue of passes all at once now, efficiently.
>        for (Module::iterator I = mod.begin(), E = mod.end(); I != E;  
> ++I)
>          if (!I->isExternal())
>            Passes.run(*I);
>
>        Passes.doFinalization();
>
> The doInitialization/doFinalization methods handle the global data.

Ahh, OK.  Thanks again for the help!

Marcel




More information about the llvm-dev mailing list