- codeGenPasses.add(createObjCARCContractPass());
-
- if (TargetMach->addPassesToEmitFile(codeGenPasses, out,
- TargetMachine::CGFT_ObjectFile)) {
- errMsg = "target file type not supported";
- return false;
- }
-
- // Run the code generator, and write object file
- codeGenPasses.run(*MergedModule);
+ preCodeGenPasses.add(createObjCARCContractPass());
+ preCodeGenPasses.run(*MergedModule);
+
+ // Do code generation. We need to preserve the module in case the client calls
+ // writeMergedModules() after compilation, but we only need to allow this at
+ // parallelism level 1. This is achieved by having splitCodeGen return the
+ // original module at parallelism level 1 which we then assign back to
+ // MergedModule.
+ MergedModule =
+ splitCodeGen(std::move(MergedModule), Out, MCpu, FeatureStr, Options,
+ RelocModel, CodeModel::Default, CGOptLevel, FileType);