@@ -296,23 +296,25 @@ static CodeGenOptLevel GetCodeGenOptLevel() {
296296 return static_cast <CodeGenOptLevel>(unsigned (CodeGenOptLevelCL));
297297}
298298
299+ namespace {
299300struct TimeTracerRAII {
300301 TimeTracerRAII (StringRef ProgramName) {
301302 if (TimeTrace)
302303 timeTraceProfilerInitialize (TimeTraceGranularity, ProgramName);
303304 }
304305 ~TimeTracerRAII () {
305- if (TimeTrace) {
306- if (auto E = timeTraceProfilerWrite (TimeTraceFile, OutputFilename)) {
307- handleAllErrors (std::move (E), [&](const StringError &SE) {
308- errs () << SE.getMessage () << " \n " ;
309- });
310- return ;
311- }
312- timeTraceProfilerCleanup ();
306+ if (!TimeTrace)
307+ return ;
308+ if (auto E = timeTraceProfilerWrite (TimeTraceFile, OutputFilename)) {
309+ handleAllErrors (std::move (E), [&](const StringError &SE) {
310+ errs () << SE.getMessage () << " \n " ;
311+ });
312+ return ;
313313 }
314+ timeTraceProfilerCleanup ();
314315 }
315316};
317+ } // namespace
316318
317319// For use in NPM transition. Currently this contains most codegen-specific
318320// passes. Remove passes from here when porting to the NPM.
@@ -377,18 +379,18 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
377379 " callbrprepare" ,
378380 " scalarizer" ,
379381 };
380- for (const auto & P : PassNamePrefix)
382+ for (StringLiteral P : PassNamePrefix)
381383 if (Pass.starts_with (P))
382384 return true ;
383- for (const auto & P : PassNameContain)
385+ for (StringLiteral P : PassNameContain)
384386 if (Pass.contains (P))
385387 return true ;
386388 return llvm::is_contained (PassNameExact, Pass);
387389}
388390
389391// For use in NPM transition.
390392static bool shouldForceLegacyPM () {
391- for (const auto & P : PassList) {
393+ for (const PassInfo * P : PassList) {
392394 StringRef Arg = P->getPassArgument ();
393395 if (shouldPinPassToLegacyPM (Arg))
394396 return true ;
@@ -399,9 +401,9 @@ static bool shouldForceLegacyPM() {
399401// ===----------------------------------------------------------------------===//
400402// main for opt
401403//
402- extern " C" int optMain (
403- int argc, char **argv,
404- ArrayRef<std::function<void (llvm:: PassBuilder &)>> PassBuilderCallbacks) {
404+ extern " C" int
405+ optMain ( int argc, char **argv,
406+ ArrayRef<std::function<void (PassBuilder &)>> PassBuilderCallbacks) {
405407 InitLLVM X (argc, argv);
406408
407409 // Enable debug stream buffering.
@@ -673,7 +675,7 @@ extern "C" int optMain(
673675 else {
674676 // Disable individual builtin functions in TargetLibraryInfo.
675677 LibFunc F;
676- for (auto &FuncName : DisableBuiltins) {
678+ for (const std::string &FuncName : DisableBuiltins) {
677679 if (TLII.getLibFunc (FuncName, F))
678680 TLII.setUnavailable (F);
679681 else {
@@ -683,7 +685,7 @@ extern "C" int optMain(
683685 }
684686 }
685687
686- for (auto &FuncName : EnableBuiltins) {
688+ for (const std::string &FuncName : EnableBuiltins) {
687689 if (TLII.getLibFunc (FuncName, F))
688690 TLII.setAvailable (F);
689691 else {
@@ -814,9 +816,8 @@ extern "C" int optMain(
814816 Passes.add (TPC);
815817 }
816818
817- // Create a new optimization pass for each one specified on the command line
818- for (unsigned i = 0 ; i < PassList.size (); ++i) {
819- const PassInfo *PassInf = PassList[i];
819+ // Create a new optimization pass for each one specified on the command line.
820+ for (const PassInfo *PassInf : PassList) {
820821 if (PassInf->getNormalCtor ()) {
821822 Pass *P = PassInf->getNormalCtor ()();
822823 if (P) {
@@ -826,9 +827,10 @@ extern "C" int optMain(
826827 if (VerifyEach)
827828 Passes.add (createVerifierPass ());
828829 }
829- } else
830+ } else {
830831 errs () << argv[0 ] << " : cannot create pass: " << PassInf->getPassName ()
831832 << " \n " ;
833+ }
832834 }
833835
834836 // Check that the module is well formed on completion of optimization
0 commit comments