@@ -44,8 +44,8 @@ using namespace lld::wasm;
4444using namespace lld ;
4545
4646static std::string getThinLTOOutputFile (StringRef modulePath) {
47- return lto::getThinLTOOutputFile (modulePath, config-> thinLTOPrefixReplaceOld ,
48- config-> thinLTOPrefixReplaceNew );
47+ return lto::getThinLTOOutputFile (modulePath, ctx. arg . thinLTOPrefixReplaceOld ,
48+ ctx. arg . thinLTOPrefixReplaceNew );
4949}
5050
5151static lto::Config createConfig () {
@@ -56,23 +56,23 @@ static lto::Config createConfig() {
5656 c.Options .FunctionSections = true ;
5757 c.Options .DataSections = true ;
5858
59- c.DisableVerify = config-> disableVerify ;
59+ c.DisableVerify = ctx. arg . disableVerify ;
6060 c.DiagHandler = diagnosticHandler;
61- c.OptLevel = config-> ltoo ;
61+ c.OptLevel = ctx. arg . ltoo ;
6262 c.MAttrs = getMAttrs ();
63- c.CGOptLevel = config-> ltoCgo ;
64- c.DebugPassManager = config-> ltoDebugPassManager ;
65- c.AlwaysEmitRegularLTOObj = !config-> ltoObjPath .empty ();
63+ c.CGOptLevel = ctx. arg . ltoCgo ;
64+ c.DebugPassManager = ctx. arg . ltoDebugPassManager ;
65+ c.AlwaysEmitRegularLTOObj = !ctx. arg . ltoObjPath .empty ();
6666
67- if (config-> relocatable )
67+ if (ctx. arg . relocatable )
6868 c.RelocModel = std::nullopt ;
6969 else if (ctx.isPic )
7070 c.RelocModel = Reloc::PIC_;
7171 else
7272 c.RelocModel = Reloc::Static;
7373
74- if (config-> saveTemps )
75- checkError (c.addSaveTemps (config-> outputFile .str () + " ." ,
74+ if (ctx. arg . saveTemps )
75+ checkError (c.addSaveTemps (ctx. arg . outputFile .str () + " ." ,
7676 /* UseInputModulePath*/ true ));
7777 return c;
7878}
@@ -81,27 +81,27 @@ namespace lld::wasm {
8181
8282BitcodeCompiler::BitcodeCompiler () {
8383 // Initialize indexFile.
84- if (!config-> thinLTOIndexOnlyArg .empty ())
85- indexFile = openFile (config-> thinLTOIndexOnlyArg );
84+ if (!ctx. arg . thinLTOIndexOnlyArg .empty ())
85+ indexFile = openFile (ctx. arg . thinLTOIndexOnlyArg );
8686
8787 // Initialize ltoObj.
8888 lto::ThinBackend backend;
8989 auto onIndexWrite = [&](StringRef s) { thinIndices.erase (s); };
90- if (config-> thinLTOIndexOnly ) {
90+ if (ctx. arg . thinLTOIndexOnly ) {
9191 backend = lto::createWriteIndexesThinBackend (
92- llvm::hardware_concurrency (config-> thinLTOJobs ),
93- std::string (config-> thinLTOPrefixReplaceOld ),
94- std::string (config-> thinLTOPrefixReplaceNew ),
95- std::string (config-> thinLTOPrefixReplaceNativeObject ),
96- config-> thinLTOEmitImportsFiles , indexFile.get (), onIndexWrite);
92+ llvm::hardware_concurrency (ctx. arg . thinLTOJobs ),
93+ std::string (ctx. arg . thinLTOPrefixReplaceOld ),
94+ std::string (ctx. arg . thinLTOPrefixReplaceNew ),
95+ std::string (ctx. arg . thinLTOPrefixReplaceNativeObject ),
96+ ctx. arg . thinLTOEmitImportsFiles , indexFile.get (), onIndexWrite);
9797 } else {
9898 backend = lto::createInProcessThinBackend (
99- llvm::heavyweight_hardware_concurrency (config-> thinLTOJobs ),
100- onIndexWrite, config-> thinLTOEmitIndexFiles ,
101- config-> thinLTOEmitImportsFiles );
99+ llvm::heavyweight_hardware_concurrency (ctx. arg . thinLTOJobs ),
100+ onIndexWrite, ctx. arg . thinLTOEmitIndexFiles ,
101+ ctx. arg . thinLTOEmitImportsFiles );
102102 }
103103 ltoObj = std::make_unique<lto::LTO>(createConfig (), backend,
104- config-> ltoPartitions );
104+ ctx. arg . ltoPartitions );
105105}
106106
107107BitcodeCompiler::~BitcodeCompiler () = default ;
@@ -123,7 +123,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
123123 ArrayRef<Symbol *> syms = f.getSymbols ();
124124 std::vector<lto::SymbolResolution> resols (syms.size ());
125125
126- if (config-> thinLTOEmitIndexFiles ) {
126+ if (ctx. arg . thinLTOEmitIndexFiles ) {
127127 thinIndices.insert (obj.getName ());
128128 }
129129
@@ -139,7 +139,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
139139 // Once IRObjectFile is fixed to report only one symbol this hack can
140140 // be removed.
141141 r.Prevailing = !objSym.isUndefined () && sym->getFile () == &f;
142- r.VisibleToRegularObj = config-> relocatable || sym->isUsedInRegularObj ||
142+ r.VisibleToRegularObj = ctx. arg . relocatable || sym->isUsedInRegularObj ||
143143 sym->isNoStrip () ||
144144 (r.Prevailing && sym->isExported ());
145145 if (r.Prevailing )
@@ -175,7 +175,7 @@ static void thinLTOCreateEmptyIndexFiles() {
175175 ModuleSummaryIndex m (/* HaveGVs*/ false );
176176 m.setSkipModuleByDistributedBackend ();
177177 writeIndexToFile (m, *os);
178- if (config-> thinLTOEmitImportsFiles )
178+ if (ctx. arg . thinLTOEmitImportsFiles )
179179 openFile (path + " .imports" );
180180 }
181181}
@@ -191,8 +191,8 @@ std::vector<StringRef> BitcodeCompiler::compile() {
191191 // to cache native object files for ThinLTO incremental builds. If a path was
192192 // specified, configure LTO to use it as the cache directory.
193193 FileCache cache;
194- if (!config-> thinLTOCacheDir .empty ())
195- cache = check (localCache (" ThinLTO" , " Thin" , config-> thinLTOCacheDir ,
194+ if (!ctx. arg . thinLTOCacheDir .empty ())
195+ cache = check (localCache (" ThinLTO" , " Thin" , ctx. arg . thinLTOCacheDir ,
196196 [&](size_t task, const Twine &moduleName,
197197 std::unique_ptr<MemoryBuffer> mb) {
198198 files[task] = std::move (mb);
@@ -210,16 +210,16 @@ std::vector<StringRef> BitcodeCompiler::compile() {
210210 for (StringRef s : thinIndices) {
211211 std::string path (s);
212212 openFile (path + " .thinlto.bc" );
213- if (config-> thinLTOEmitImportsFiles )
213+ if (ctx. arg . thinLTOEmitImportsFiles )
214214 openFile (path + " .imports" );
215215 }
216216
217- if (config-> thinLTOEmitIndexFiles )
217+ if (ctx. arg . thinLTOEmitIndexFiles )
218218 thinLTOCreateEmptyIndexFiles ();
219219
220- if (config-> thinLTOIndexOnly ) {
221- if (!config-> ltoObjPath .empty ())
222- saveBuffer (buf[0 ].second , config-> ltoObjPath );
220+ if (ctx. arg . thinLTOIndexOnly ) {
221+ if (!ctx. arg . ltoObjPath .empty ())
222+ saveBuffer (buf[0 ].second , ctx. arg . ltoObjPath );
223223
224224 // ThinLTO with index only option is required to generate only the index
225225 // files. After that, we exit from linker and ThinLTO backend runs in a
@@ -229,8 +229,8 @@ std::vector<StringRef> BitcodeCompiler::compile() {
229229 return {};
230230 }
231231
232- if (!config-> thinLTOCacheDir .empty ())
233- pruneCache (config-> thinLTOCacheDir , config-> thinLTOCachePolicy , files);
232+ if (!ctx. arg . thinLTOCacheDir .empty ())
233+ pruneCache (ctx. arg . thinLTOCacheDir , ctx. arg . thinLTOCachePolicy , files);
234234
235235 std::vector<StringRef> ret;
236236 for (unsigned i = 0 ; i != maxTasks; ++i) {
@@ -239,7 +239,7 @@ std::vector<StringRef> BitcodeCompiler::compile() {
239239 if (objBuf.empty ())
240240 continue ;
241241 ret.emplace_back (objBuf.data (), objBuf.size ());
242- if (!config-> saveTemps )
242+ if (!ctx. arg . saveTemps )
243243 continue ;
244244
245245 // If the input bitcode file is path/to/x.o and -o specifies a.out, the
@@ -248,7 +248,7 @@ std::vector<StringRef> BitcodeCompiler::compile() {
248248 StringRef ltoObjName;
249249 if (bitcodeFilePath == " ld-temp.o" ) {
250250 ltoObjName =
251- saver ().save (Twine (config-> outputFile ) + " .lto" +
251+ saver ().save (Twine (ctx. arg . outputFile ) + " .lto" +
252252 (i == 0 ? Twine (" " ) : Twine (' .' ) + Twine (i)) + " .o" );
253253 } else {
254254 StringRef directory = sys::path::parent_path (bitcodeFilePath);
@@ -258,7 +258,7 @@ std::vector<StringRef> BitcodeCompiler::compile() {
258258 StringRef baseName = bitcodeFilePath.ends_with (" )" )
259259 ? sys::path::filename (bitcodeFilePath)
260260 : sys::path::stem (bitcodeFilePath);
261- StringRef outputFileBaseName = sys::path::filename (config-> outputFile );
261+ StringRef outputFileBaseName = sys::path::filename (ctx. arg . outputFile );
262262 SmallString<256 > path;
263263 sys::path::append (path, directory,
264264 outputFileBaseName + " .lto." + baseName + " .o" );
@@ -268,10 +268,10 @@ std::vector<StringRef> BitcodeCompiler::compile() {
268268 saveBuffer (objBuf, ltoObjName);
269269 }
270270
271- if (!config-> ltoObjPath .empty ()) {
272- saveBuffer (buf[0 ].second , config-> ltoObjPath );
271+ if (!ctx. arg . ltoObjPath .empty ()) {
272+ saveBuffer (buf[0 ].second , ctx. arg . ltoObjPath );
273273 for (unsigned i = 1 ; i != maxTasks; ++i)
274- saveBuffer (buf[i].second , config-> ltoObjPath + Twine (i));
274+ saveBuffer (buf[i].second , ctx. arg . ltoObjPath + Twine (i));
275275 }
276276
277277 for (std::unique_ptr<MemoryBuffer> &file : files)
0 commit comments