[PATCH] D63976: Allow clang -Os and -Oz to work with -flto and lld
Stephen Checkoway via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 29 14:14:33 PDT 2019
> On Jun 29, 2019, at 15:38, Bernhard Rosenkränzer via Phabricator via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> bero created this revision.
> bero added a reviewer: llvm-commits.
> bero added a project: clang.
> Herald added subscribers: cfe-commits, dexonsmith, inglorion, mehdi_amini.
>
> Fix clang -Os/-Oz with LTO
>
> $ clang -Os -fuse-ld=lld -flto test.c
> ld.lld: error: -plugin-opt=Os: number expected, but got 's'
> clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
> $ clang -Oz -fuse-ld=lld -flto test.c
> ld.lld: error: -plugin-opt=Oz: number expected, but got 'z'
> clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
>
> https://bugs.llvm.org/show_bug.cgi?id=42445
>
>
> Repository:
> rC Clang
>
> https://reviews.llvm.org/D63976
>
> Files:
> llvm-9.0.0-20190629/clang/lib/Driver/ToolChains/CommonArgs.cpp
>
>
> Index: llvm-9.0.0-20190629/clang/lib/Driver/ToolChains/CommonArgs.cpp
> ===================================================================
> --- llvm-9.0.0-20190629/clang/lib/Driver/ToolChains/CommonArgs.cpp
> +++ llvm-9.0.0-20190629/clang/lib/Driver/ToolChains/CommonArgs.cpp
> @@ -389,8 +389,11 @@
> if (A->getOption().matches(options::OPT_O4) ||
> A->getOption().matches(options::OPT_Ofast))
> OOpt = "3";
> - else if (A->getOption().matches(options::OPT_O))
> + else if (A->getOption().matches(options::OPT_O)) {
> OOpt = A->getValue();
> + if(OOpt == "s" || OOpt == "z")
> + OOpt = "3";
> + }
Is this going to enable inlining? A user might be quite surprised to find multiple inlined versions of a function when compiled with -Os and especially with -Oz.
> else if (A->getOption().matches(options::OPT_O0))
> OOpt = "0";
> if (!OOpt.empty())
>
>
> <D63976.207208.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
--
Stephen Checkoway
More information about the cfe-commits
mailing list