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

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 09:59:07 PST 2023


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


================
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;
----------------
scott.linder wrote:
> 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.
Ah, my mistake, I didn't see the call to `checkOptions` that I was hoisting the `assert` over. Like you say, this is adding an assert incorrectly. I will update the patch to handle the error in `checkOptions` instead.


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