[PATCH] D28053: Cleanup the handling of noinline function attributes, -fno-inline, -fno-inline-functions, -O0, and optnone.
Mehdi AMINI via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 22 10:22:22 PST 2016
mehdi_amini added inline comments.
================
Comment at: lib/Frontend/CompilerInvocation.cpp:453
+ // There is no effect at O0 when we won't inline anyways.
+ if (Opts.OptimizationLevel > 1) {
+ const Option &InlineOpt = InlineArg->getOption();
----------------
mehdi_amini wrote:
> I'd switch the two if
The test `> 1` and the comment about `-O0` are confusing to me as well. What about the following (IIUC):
```
if (Opts.OptimizationLevel <= 1) {
// "always-inline" required for correctness at O0 and O1.
Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
else if (Opts.OptimizationLevel > 1) {
// Normal inlining at O2 and above
Opts.setInlining((CodeGenOptions::NormalInlining);
// -fno-inline-functions overrides
if (Arg *InlineArg = Args.getLastArg(
options::OPT_finline_functions, options::OPT_finline_hint_functions,
options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
if (InlineOpt.matches(options::OPT_finline_functions))
Opts.setInlining(CodeGenOptions::NormalInlining);
else if (InlineOpt.matches(options::OPT_finline_hint_functions))
Opts.setInlining(CodeGenOptions::OnlyHintInlining);
else
Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
}
}
```
https://reviews.llvm.org/D28053
More information about the cfe-commits
mailing list