opt: Adding -O0 to opt tool

Summary:
Having -O0 in opt allows testing that -O0 optimization
pipeline is built correctly.

Reviewers: majnemer

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D23208

llvm-svn: 277829
This commit is contained in:
Gor Nishanov 2016-08-05 16:27:33 +00:00
parent b4022f9782
commit f3bb361750
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,7 @@
; Test that all coroutine passes run in the correct order at all optimization
; levels and -disable-coroutines removes coroutine passes from the pipeline.
;
; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O0 2>&1 | FileCheck %s
; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O1 2>&1 | FileCheck %s
; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O2 2>&1 | FileCheck %s
; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O3 2>&1 | FileCheck %s

View File

@ -121,6 +121,10 @@ static cl::opt<bool>
StandardLinkOpts("std-link-opts",
cl::desc("Include the standard link time optimizations"));
static cl::opt<bool>
OptLevelO0("O0",
cl::desc("Optimization level 0. Similar to clang -O0"));
static cl::opt<bool>
OptLevelO1("O1",
cl::desc("Optimization level 1. Similar to clang -O1"));
@ -515,7 +519,8 @@ int main(int argc, char **argv) {
: TargetIRAnalysis()));
std::unique_ptr<legacy::FunctionPassManager> FPasses;
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
if (OptLevelO0 || OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz ||
OptLevelO3) {
FPasses.reset(new legacy::FunctionPassManager(M.get()));
FPasses->add(createTargetTransformInfoWrapperPass(
TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis()));
@ -547,6 +552,11 @@ int main(int argc, char **argv) {
StandardLinkOpts = false;
}
if (OptLevelO0 && OptLevelO0.getPosition() < PassList.getPosition(i)) {
AddOptimizationPasses(Passes, *FPasses, TM.get(), 0, 0);
OptLevelO0 = false;
}
if (OptLevelO1 && OptLevelO1.getPosition() < PassList.getPosition(i)) {
AddOptimizationPasses(Passes, *FPasses, TM.get(), 1, 0);
OptLevelO1 = false;
@ -619,6 +629,9 @@ int main(int argc, char **argv) {
StandardLinkOpts = false;
}
if (OptLevelO0)
AddOptimizationPasses(Passes, *FPasses, TM.get(), 0, 0);
if (OptLevelO1)
AddOptimizationPasses(Passes, *FPasses, TM.get(), 1, 0);