addPassesToEmit(Whole)File changes?

Hi folks,

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.

Any pointers?

Thanks!

Marcel

This is my current code:

-(void)dumpAssemblerToFile:(NSString*)filename
{
  TargetMachine::CodeGenFileType FileType = TargetMachine::AssemblyFile;
  std::string err1;
  Module *M=(Module*)module;
  const TargetMachineRegistry::Entry* entry= TargetMachineRegistry::getClosestStaticTargetForModule( *M, err1 );
  TargetMachine &target=*entry->CtorFn( *M, "" );
  [self generateMethodLists];
  std::ostream *outStream = 0;
  PassManager passes;
  outStream = new std::ofstream( [filename fileSystemRepresentation] );
  TargetData *data =new TargetData( *target.getTargetData());
  passes.add(data);
  target.addPassesToEmitFile(passes, *outStream, FileType, false);
  passes.run(*M);
  delete outStream;
}