just installed the new llvm 1.9 build and noticed that my code no longer worked. It seems something has changed with addPassesToEmitFile(). First, the arguments to that method changed so that it no longer takes a PassManager, but only a FunctionPassManager. Instead there is a addPassesToEmitWholeFile() method, but that is marked as optional, and when I change my code to use that there is no output (only an empty file).
I tried changing to code to use a FunctionPassManager, but that then requires the run() call to be changed to individual functions, and I am not convinced I want to do that because what I am outputting are not just functions, but also some global data.
I am currently installing older versions to see if that will work, but of course I will need to get it to work with the newest llvm version at some point.
This is my current code:
TargetMachine::CodeGenFileType FileType = TargetMachine::AssemblyFile;
const TargetMachineRegistry::Entry* entry= TargetMachineRegistry::getClosestStaticTargetForModule( *M, err1 );
TargetMachine &target=*entry->CtorFn( *M, "" );
std::ostream *outStream = 0;
outStream = new std::ofstream( [filename fileSystemRepresentation] );
TargetData *data =new TargetData( *target.getTargetData());
target.addPassesToEmitFile(passes, *outStream, FileType, false);