Hi, > void optimizeFunction(std::string functionName, llvm::Module* mod) { > llvm::Function* f = mod->getFunction(functionName); > > llvm::ExistingModuleProvider mp(mod); > llvm::FunctionPassManager fpm(&mp); maybe when you leave this function the above two objects are being finalized and freeing memory? Ciao, Duncan.