r291276 - Use CodegenOpts::less when creating a TargetMachine for clang `-O1`
Mehdi Amini via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 6 12:52:30 PST 2017
Author: mehdi_amini
Date: Fri Jan 6 14:52:30 2017
New Revision: 291276
URL: http://llvm.org/viewvc/llvm-project?rev=291276&view=rev
Log:
Use CodegenOpts::less when creating a TargetMachine for clang `-O1`
Summary:
Clang was initializing the TargetMachine with CodeGenOpt::Default
for O1. This change is aligning it on llc:
-O0: OptLevel = CodeGenOpt::None
-O1: OptLevel = CodeGenOpt::Less
-O2 -Os -Oz: OptLevel = CodeGenOpt::Default
-O3: OptLevel = CodeGenOpt::Aggressive
Reviewers: echristo, chandlerc
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D28409
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291276&r1=291275&r2=291276&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan 6 14:52:30 2017
@@ -519,11 +519,22 @@ void EmitAssemblyHelper::CreateTargetMac
.Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
assert(RM.hasValue() && "invalid PIC model!");
- CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
+ CodeGenOpt::Level OptLevel;
switch (CodeGenOpts.OptimizationLevel) {
- default: break;
- case 0: OptLevel = CodeGenOpt::None; break;
- case 3: OptLevel = CodeGenOpt::Aggressive; break;
+ default:
+ llvm_unreachable("Invalid optimization level!");
+ case 0:
+ OptLevel = CodeGenOpt::None;
+ break;
+ case 1:
+ OptLevel = CodeGenOpt::Less;
+ break;
+ case 2:
+ OptLevel = CodeGenOpt::Default;
+ break; // O2/Os/Oz
+ case 3:
+ OptLevel = CodeGenOpt::Aggressive;
+ break;
}
llvm::TargetOptions Options;
More information about the cfe-commits
mailing list