From 54c2910692bcfc9104e18a4db9bf4cd94ae19049 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 8 Aug 2013 08:34:35 +0000 Subject: The only useful loop unrolling flag to give realistically is '-fno-unroll-loops'. The option to the backend is even called 'DisableUnrollLoops'. This is precisely the form that Clang *didn't* support. We didn't recognize the flag, we didn't pass it to the CC1 layer, and even if we did we wouldn't use it. Clang only inspected the positive form of the flag, and only did so to enable loop unrolling when the optimization level wasn't high enough. This only occurs for an optimization level that even has a chance of running the loop unroller when optimizing for size. This commit wires up the 'no' variant, and switches the code to actually follow the standard flag pattern of using the last flag and allowing a flag in either direction to override the default. I think this is still wrong. I don't know why we disable the loop unroller entirely *from Clang* when optimizing for size, as the loop unrolling pass *already has special logic* for the case where the function is attributed as optimized for size! We should really be trusting that. Maybe in a follow-up patch, I don't really want to change behavior here. llvm-svn: 187969 --- clang/lib/Frontend/CompilerInvocation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index a4c93fa5b50..f88c124f08c 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -351,8 +351,9 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.OptimizeSize = getOptimizationLevelSize(Args); Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) || Args.hasArg(OPT_ffreestanding)); - Opts.UnrollLoops = Args.hasArg(OPT_funroll_loops) || - (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize); + Opts.UnrollLoops = + Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops, + (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize)); Opts.Autolink = !Args.hasArg(OPT_fno_autolink); Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose); -- cgit v1.2.3