[Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og
authorFangrui Song <maskray@google.com>
Thu, 14 May 2020 00:16:54 +0000 (17:16 -0700)
committerFangrui Song <maskray@google.com>
Thu, 14 May 2020 17:37:33 +0000 (10:37 -0700)
commit5ecb51414637402b0f89a96924ac7b015d23bcfa
tree0a8d989612f8349ef247f69b934661207086c361
parentf5a79713b612376baae54cb47c8ec87b14f4b9b3
[Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

Fixes PR42445 (compiler driver options -Os -Oz translate to
-plugin-opt=Os (Oz) which are not recognized by LLVMgold.so or LLD).

The optimization level mapping matches
CompilerInvocation.cpp:getOptimizationLevel() and SpeedLevel of
PassBuilder::OptimizationLevel::O*.

-plugin-opt=O* affects the way we construct regular LTO/ThinLTO pass
manager pipeline.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D79919
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/lto.c