@@ -582,7 +582,8 @@ void ThinLTOCodeGenerator::crossReferenceSymbol(StringRef Name) {
582582}
583583
584584// TargetMachine factory
585- std::unique_ptr<TargetMachine> TargetMachineBuilder::create () const {
585+ std::unique_ptr<TargetMachine>
586+ TargetMachineBuilder::create (const Module &M) const {
586587 std::string ErrMsg;
587588 const Target *TheTarget =
588589 TargetRegistry::lookupTarget (TheTriple.str (), ErrMsg);
@@ -592,7 +593,7 @@ std::unique_ptr<TargetMachine> TargetMachineBuilder::create() const {
592593
593594 // Use MAttr as the default set of features.
594595 SubtargetFeatures Features (MAttr);
595- Features.getDefaultSubtargetFeatures (TheTriple );
596+ Features.getDefaultSubtargetFeatures (M );
596597 std::string FeatureStr = Features.getString ();
597598
598599 std::unique_ptr<TargetMachine> TM (
@@ -920,8 +921,8 @@ void ThinLTOCodeGenerator::optimize(Module &TheModule) {
920921 initTMBuilder (TMBuilder, Triple (TheModule.getTargetTriple ()));
921922
922923 // Optimize now
923- optimizeModule (TheModule, *TMBuilder.create (), OptLevel, Freestanding ,
924- DebugPassManager, nullptr );
924+ optimizeModule (TheModule, *TMBuilder.create (TheModule ), OptLevel,
925+ Freestanding, DebugPassManager, nullptr );
925926}
926927
927928// / Write out the generated object file, either from CacheEntryPath or from
@@ -997,7 +998,8 @@ void ThinLTOCodeGenerator::run() {
997998 /* IsImporting*/ false );
998999
9991000 // CodeGen
1000- auto OutputBuffer = codegenModule (*TheModule, *TMBuilder.create ());
1001+ TargetMachine &TM = *TMBuilder.create (*TheModule);
1002+ auto OutputBuffer = codegenModule (*TheModule, TM);
10011003 if (SavedObjectsDirectoryPath.empty ())
10021004 ProducedBinaries[count] = std::move (OutputBuffer);
10031005 else
@@ -1185,13 +1187,13 @@ void ThinLTOCodeGenerator::run() {
11851187 saveTempBitcode (*TheModule, SaveTempsDir, count, " .0.original.bc" );
11861188
11871189 auto &ImportList = ImportLists[ModuleIdentifier];
1190+ TargetMachine &TM = *TMBuilder.create (*TheModule);
11881191 // Run the main process now, and generates a binary
11891192 auto OutputBuffer = ProcessThinLTOModule (
1190- *TheModule, *Index, ModuleMap, *TMBuilder.create (), ImportList,
1191- ExportList, GUIDPreservedSymbols,
1192- ModuleToDefinedGVSummaries[ModuleIdentifier], CacheOptions,
1193- DisableCodeGen, SaveTempsDir, Freestanding, OptLevel, count,
1194- DebugPassManager);
1193+ *TheModule, *Index, ModuleMap, TM, ImportList, ExportList,
1194+ GUIDPreservedSymbols, ModuleToDefinedGVSummaries[ModuleIdentifier],
1195+ CacheOptions, DisableCodeGen, SaveTempsDir, Freestanding, OptLevel,
1196+ count, DebugPassManager);
11951197
11961198 // Commit to the cache (if enabled)
11971199 CacheEntry.write (*OutputBuffer);
0 commit comments