diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:09:33 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:09:33 +0000 |
commit | 3fd58f91dd318518f7daa4ba64c0aaf31799d89b (patch) | |
tree | 74eecbae571601ec6a626a53374b1eddc7b164a5 /tools/opt/opt.cpp | |
parent | 3fba7d16b41dfbefe3b1be6bc0ab94c017728f79 (diff) | |
download | FreeBSD-src-3fd58f91dd318518f7daa4ba64c0aaf31799d89b.zip FreeBSD-src-3fd58f91dd318518f7daa4ba64c0aaf31799d89b.tar.gz |
Update LLVM to r94309.
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r-- | tools/opt/opt.cpp | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index a636bd9..6ed8c9d 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -288,7 +288,17 @@ void AddOptimizationPasses(PassManager &MPM, FunctionPassManager &FPM, unsigned OptLevel) { createStandardFunctionPasses(&FPM, OptLevel); - llvm::Pass *InliningPass = OptLevel > 1 ? createFunctionInliningPass() : 0; + llvm::Pass *InliningPass = 0; + if (DisableInline) { + // No inlining pass + } else if (OptLevel) { + unsigned Threshold = 200; + if (OptLevel > 2) + Threshold = 250; + InliningPass = createFunctionInliningPass(Threshold); + } else { + InliningPass = createAlwaysInlinerPass(); + } createStandardModulePasses(&MPM, OptLevel, /*OptimizeSize=*/ false, UnitAtATime, @@ -373,24 +383,29 @@ int main(int argc, char **argv) { // FIXME: outs() is not binary! raw_ostream *Out = &outs(); // Default to printing to stdout... if (OutputFilename != "-") { - // Make sure that the Output file gets unlinked from the disk if we get a - // SIGINT - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - - std::string ErrorInfo; - Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary); - if (!ErrorInfo.empty()) { - errs() << ErrorInfo << '\n'; - delete Out; - return 1; + if (NoOutput || AnalyzeOnly) { + errs() << "WARNING: The -o (output filename) option is ignored when\n" + "the --disable-output or --analyze options are used.\n"; + } else { + // Make sure that the Output file gets unlinked from the disk if we get a + // SIGINT + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + std::string ErrorInfo; + Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary); + if (!ErrorInfo.empty()) { + errs() << ErrorInfo << '\n'; + delete Out; + return 1; + } } } // If the output is set to be emitted to standard out, and standard out is a // console, print out a warning message and refuse to do it. We don't // impress anyone by spewing tons of binary goo to a terminal. - if (!Force && !NoOutput && !OutputAssembly) + if (!Force && !NoOutput && !AnalyzeOnly && !OutputAssembly) if (CheckBitcodeOutputToConsole(*Out, !Quiet)) NoOutput = true; @@ -461,24 +476,26 @@ int main(int argc, char **argv) { errs() << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { - bool isBBPass = dynamic_cast<BasicBlockPass*>(P) != 0; - bool isLPass = !isBBPass && dynamic_cast<LoopPass*>(P) != 0; - bool isFPass = !isLPass && dynamic_cast<FunctionPass*>(P) != 0; - bool isCGSCCPass = !isFPass && dynamic_cast<CallGraphSCCPass*>(P) != 0; - addPass(Passes, P); if (AnalyzeOnly) { - if (isBBPass) + switch (P->getPassKind()) { + case PT_BasicBlock: Passes.add(new BasicBlockPassPrinter(PassInf)); - else if (isLPass) + break; + case PT_Loop: Passes.add(new LoopPassPrinter(PassInf)); - else if (isFPass) + break; + case PT_Function: Passes.add(new FunctionPassPrinter(PassInf)); - else if (isCGSCCPass) + break; + case PT_CallGraphSCC: Passes.add(new CallGraphSCCPassPrinter(PassInf)); - else + break; + default: Passes.add(new ModulePassPrinter(PassInf)); + break; + } } } @@ -517,7 +534,7 @@ int main(int argc, char **argv) { if (!NoVerify && !VerifyEach) Passes.add(createVerifierPass()); - // Write bitcode or assembly out to disk or outs() as the last step... + // Write bitcode or assembly out to disk or outs() as the last step... if (!NoOutput && !AnalyzeOnly) { if (OutputAssembly) Passes.add(createPrintModulePass(Out)); |