# HG changeset patch # User Frits van Bommel # Date 1238334674 -7200 # Node ID 461a85f0db317bfb127448a23974cb2aba4acd78 # Parent e40c65bd8c5d7616aeb4a451c3e5d845440dbfff Change meaning of optimization levels: -O0 now means 'no optimization' like with other compilers. diff -r e40c65bd8c5d -r 461a85f0db31 gen/linker.cpp --- a/gen/linker.cpp Sun Mar 29 15:46:55 2009 +0200 +++ b/gen/linker.cpp Sun Mar 29 15:51:14 2009 +0200 @@ -121,9 +121,9 @@ { case 0: args.push_back("-disable-opt"); - args.push_back("-globaldce"); break; case 1: + args.push_back("-globaldce"); args.push_back("-disable-opt"); args.push_back("-globaldce"); args.push_back("-mem2reg"); diff -r e40c65bd8c5d -r 461a85f0db31 gen/optimizer.cpp --- a/gen/optimizer.cpp Sun Mar 29 15:46:55 2009 +0200 +++ b/gen/optimizer.cpp Sun Mar 29 15:51:14 2009 +0200 @@ -24,14 +24,14 @@ cl::ZeroOrMore, cl::values( clEnumValN(2, "O", "Equivalent to -O2"), - clEnumValN(0, "O0", "Trivial optimizations only"), + clEnumValN(0, "O0", "No optimizations (default)"), clEnumValN(1, "O1", "Simple optimizations"), clEnumValN(2, "O2", "Good optimizations"), clEnumValN(3, "O3", "Aggressive optimizations"), clEnumValN(4, "O4", "Link-time optimization"), // not implemented? clEnumValN(5, "O5", "Link-time optimization"), // not implemented? clEnumValEnd), - cl::init(-1)); + cl::init(0)); static cl::opt enableInlining("enable-inlining", cl::desc("Enable function inlining (in -O, if given)"), @@ -48,22 +48,17 @@ } bool optimize() { - return (optimizeLevel != -1) || enableInlining || passList.empty(); + return optimizeLevel || enableInlining || passList.empty(); } // this function inserts some or all of the std-compile-opts passes depending on the // optimization level given. static void addPassesForOptLevel(PassManager& pm) { - // -O0 - if (optimizeLevel >= 0) + // -O1 + if (optimizeLevel >= 1) { //pm.add(createStripDeadPrototypesPass()); pm.add(createGlobalDCEPass()); - } - - // -O1 - if (optimizeLevel >= 1) - { pm.add(createRaiseAllocationsPass()); pm.add(createCFGSimplificationPass()); pm.add(createPromoteMemoryToRegisterPass()); @@ -129,15 +124,15 @@ // Returns true if any optimization passes were invoked. bool ldc_optimize_module(llvm::Module* m) { - if (!enableInlining && optimizeLevel == -1 && passList.empty()) + if (!enableInlining && optimizeLevel == 0 && passList.empty()) return false; PassManager pm; pm.add(new TargetData(m)); - bool optimize = (optimizeLevel != -1) || enableInlining; + bool optimize = optimizeLevel != 0 || enableInlining; - unsigned optPos = optimizeLevel != -1 + unsigned optPos = optimizeLevel != 0 ? optimizeLevel.getPosition() : enableInlining.getPosition();