[PATCH] D141970: [Clang][LLD] Add --lto-CGO[0-3] option

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 12:50:27 PST 2023


scott.linder marked an inline comment as done.
scott.linder added inline comments.


================
Comment at: lld/COFF/Driver.cpp:1774
           error("/opt:lldlto: invalid optimization level: " + optLevel);
+      } else if (s.startswith("lldltocgo=")) {
+        StringRef optLevel = s.substr(10);
----------------
MaskRay wrote:
> `s.consume_front(...)` then just use `s` below
Done as part of rebasing


================
Comment at: lld/wasm/Driver.cpp:429
+      args::getInteger(args, OPT_lto_CGO, args::getCGOptLevel(config->ltoo)));
+  assert(optLevelOrNone && "Invalid optimization level!");
+  config->ltocgo = *optLevelOrNone;
----------------
MaskRay wrote:
> This introduces a crash in an assertion build if ltoo is larger than 3.
> A proper error message like existing `invalid optimization level` should be used.
This doesn't add a new assert, it moves it from `LTO.cpp` to `Driver.cpp` and incorporates an option to control the input directly.

I avoided changing the behavior from an `assert` to an `error` to limit the tail of the refactor, but I can add a patch preceding this one to so.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141970/new/

https://reviews.llvm.org/D141970



More information about the llvm-commits mailing list