[llvm] r277829 - opt: Adding -O0 to opt tool
Gor Nishanov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 09:27:33 PDT 2016
Author: gornishanov
Date: Fri Aug 5 11:27:33 2016
New Revision: 277829
URL: http://llvm.org/viewvc/llvm-project?rev=277829&view=rev
Log:
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
Modified:
llvm/trunk/test/Transforms/Coroutines/smoketest.ll
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/test/Transforms/Coroutines/smoketest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Coroutines/smoketest.ll?rev=277829&r1=277828&r2=277829&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Coroutines/smoketest.ll (original)
+++ llvm/trunk/test/Transforms/Coroutines/smoketest.ll Fri Aug 5 11:27:33 2016
@@ -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
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=277829&r1=277828&r2=277829&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Fri Aug 5 11:27:33 2016
@@ -122,6 +122,10 @@ 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);
More information about the llvm-commits
mailing list