зеркало из https://github.com/microsoft/clang-1.git
Add -Oz option and use it to set the inline threshold to 25.
Radar 9333566. Patch by Chad Rosier! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130554 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
73a6f8e8ad
Коммит
a0fa203f04
|
@ -179,6 +179,7 @@ def mms_bitfields : Flag<"-mms-bitfields">,
|
|||
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard.">;
|
||||
def O : Joined<"-O">, HelpText<"Optimization level">;
|
||||
def Os : Flag<"-Os">, HelpText<"Optimize for size">;
|
||||
def Oz : Flag<"-Oz">, HelpText<"Optimize for size, regardless of performance">;
|
||||
def pg : Flag<"-pg">, HelpText<"Enable mcount instrumentation">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
|
||||
/// enabled.
|
||||
unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
|
||||
unsigned OptimizeSize : 1; /// If -Os is specified.
|
||||
unsigned OptimizeSize : 2; /// If -Os (==1) or -Oz (==2) is specified.
|
||||
unsigned RelaxAll : 1; /// Relax all machine code instructions.
|
||||
unsigned RelaxedAliasing : 1; /// Set when -fno-strict-aliasing is enabled.
|
||||
unsigned SaveTempLabels : 1; /// Save temporary labels.
|
||||
|
|
|
@ -134,8 +134,10 @@ void EmitAssemblyHelper::CreatePasses() {
|
|||
//
|
||||
// FIXME: Derive these constants in a principled fashion.
|
||||
unsigned Threshold = 225;
|
||||
if (CodeGenOpts.OptimizeSize)
|
||||
if (CodeGenOpts.OptimizeSize == 1) //-Os
|
||||
Threshold = 75;
|
||||
else if (CodeGenOpts.OptimizeSize == 2) //-Oz
|
||||
Threshold = 25;
|
||||
else if (OptLevel > 2)
|
||||
Threshold = 275;
|
||||
InliningPass = createFunctionInliningPass(Threshold);
|
||||
|
|
|
@ -1309,10 +1309,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
else if (A->getOption().matches(options::OPT_O) &&
|
||||
A->getValue(Args)[0] == '\0')
|
||||
CmdArgs.push_back("-O2");
|
||||
else if (A->getOption().matches(options::OPT_O) &&
|
||||
A->getValue(Args)[0] == 'z' &&
|
||||
A->getValue(Args)[1] == '\0')
|
||||
CmdArgs.push_back("-Os");
|
||||
else
|
||||
A->render(Args, CmdArgs);
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
|
|||
Res.push_back("-momit-leaf-frame-pointer");
|
||||
if (Opts.OptimizeSize) {
|
||||
assert(Opts.OptimizationLevel == 2 && "Invalid options!");
|
||||
Res.push_back("-Os");
|
||||
Opts.OptimizeSize == 1 ? Res.push_back("-Os") : Res.push_back("-Oz");
|
||||
} else if (Opts.OptimizationLevel != 0)
|
||||
Res.push_back("-O" + llvm::utostr(Opts.OptimizationLevel));
|
||||
if (!Opts.MainFileName.empty()) {
|
||||
|
@ -815,8 +815,8 @@ static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
|
|||
unsigned DefaultOpt = 0;
|
||||
if (IK == IK_OpenCL && !Args.hasArg(OPT_cl_opt_disable))
|
||||
DefaultOpt = 2;
|
||||
// -Os implies -O2
|
||||
return Args.hasArg(OPT_Os) ? 2 :
|
||||
// -Os/-Oz implies -O2
|
||||
return (Args.hasArg(OPT_Os) || Args.hasArg (OPT_Oz)) ? 2 :
|
||||
Args.getLastArgIntValue(OPT_O, DefaultOpt, Diags);
|
||||
}
|
||||
|
||||
|
@ -931,6 +931,7 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.NoCommon = Args.hasArg(OPT_fno_common);
|
||||
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
|
||||
Opts.OptimizeSize = Args.hasArg(OPT_Os);
|
||||
Opts.OptimizeSize = Args.hasArg(OPT_Oz) ? 2 : Opts.OptimizeSize;
|
||||
Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
|
||||
Args.hasArg(OPT_ffreestanding));
|
||||
Opts.UnrollLoops = Args.hasArg(OPT_funroll_loops) ||
|
||||
|
|
Загрузка…
Ссылка в новой задаче