LLVM 22.0.0git
OptBisect.cpp File Reference

This file implements support for a bisecting optimizations based on a command line option. More...

#include "llvm/IR/OptBisect.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/IntegerInclusiveInterval.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdlib>

Go to the source code of this file.

Functions

static OptBisectgetOptBisector ()
static OptDisablegetOptDisabler ()
static void printPassMessage (StringRef Name, int PassNum, StringRef TargetDesc, bool Running)
static void printDisablePassMessage (const StringRef &Name, StringRef TargetDesc, bool Running)

Variables

static cl::opt< int > OptBisectLimit ("opt-bisect-limit", cl::Hidden, cl::init(-1), cl::Optional, cl::cb< void, int >([](int Limit) { if(Limit==-1) getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}});else if(Limit==0) getOptBisector().setIntervals({{0, 0}});else if(Limit > 0) getOptBisector().setIntervals({{1, Limit}});else llvm_unreachable(("Invalid limit for -opt-bisect-limit: "+llvm::utostr(Limit)) .c_str());}), cl::desc("Maximum optimization to perform (equivalent to -opt-bisect=1-N)"))
static cl::opt< std::stringOptBisectIntervals ("opt-bisect", cl::Hidden, cl::Optional, cl::cb< void, const std::string & >([](const std::string &IntervalStr) { if(IntervalStr=="-1") { getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}});return;} auto Intervals=IntegerInclusiveIntervalUtils::parseIntervals(IntervalStr);if(!Intervals) { handleAllErrors(Intervals.takeError(), [&](const StringError &E) { errs()<< "Error: Invalid interval specification for -opt-bisect: "<< IntervalStr<< " ("<< E.getMessage()<< ")\n";});exit(1);} getOptBisector().setIntervals(std::move(*Intervals));}), cl::desc("Run optimization passes only for the specified intervals. " "Format: '1-10,20-30,45' runs passes 1-10, 20-30, and 45, where " "index 1 is the first pass. Supply '0' to run no passes and -1 to " "run all passes."))
static cl::opt< boolOptBisectVerbose ("opt-bisect-verbose", cl::desc("Show verbose output when opt-bisect-limit is set"), cl::Hidden, cl::init(true), cl::Optional)
static cl::list< std::stringOptDisablePasses ("opt-disable", cl::Hidden, cl::CommaSeparated, cl::Optional, cl::cb< void, std::string >([](const std::string &Pass) { getOptDisabler().setDisabled(Pass);}), cl::desc("Optimization pass(es) to disable (comma-separated list)"))
static cl::opt< boolOptDisableVerbose ("opt-disable-enable-verbosity", cl::desc("Show verbose output when opt-disable is set"), cl::Hidden, cl::init(false), cl::Optional)

Detailed Description

This file implements support for a bisecting optimizations based on a command line option.

Definition in file OptBisect.cpp.

Function Documentation

◆ getOptBisector()

OptBisect & getOptBisector ( )
static

Definition at line 26 of file OptBisect.cpp.

Referenced by llvm::getGlobalPassGate().

◆ getOptDisabler()

OptDisable & getOptDisabler ( )
static

Definition at line 31 of file OptBisect.cpp.

Referenced by llvm::getGlobalPassGate().

◆ printDisablePassMessage()

void printDisablePassMessage ( const StringRef & Name,
StringRef TargetDesc,
bool Running )
static

Definition at line 120 of file OptBisect.cpp.

References llvm::dbgs().

Referenced by llvm::OptDisable::shouldRunPass().

◆ printPassMessage()

void printPassMessage ( StringRef Name,
int PassNum,
StringRef TargetDesc,
bool Running )
static

Definition at line 98 of file OptBisect.cpp.

References llvm::errs().

Referenced by llvm::OptBisect::shouldRunPass().

Variable Documentation

◆ OptBisectIntervals

cl::opt< std::string > OptBisectIntervals("opt-bisect", cl::Hidden, cl::Optional, cl::cb< void, const std::string & >([](const std::string &IntervalStr) { if(IntervalStr=="-1") { getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}}); return; } auto Intervals= IntegerInclusiveIntervalUtils::parseIntervals(IntervalStr); if(!Intervals) { handleAllErrors(Intervals.takeError(),[&](const StringError &E) { errs()<< "Error: Invalid interval specification for -opt-bisect: "<< IntervalStr<< " ("<< E.getMessage()<< ")\n"; }); exit(1); } getOptBisector().setIntervals(std::move(*Intervals)); }), cl::desc("Run optimization passes only for the specified intervals. " "Format: '1-10,20-30,45' runs passes 1-10, 20-30, and 45, where " "index 1 is the first pass. Supply '0' to run no passes and -1 to " "run all passes.")) ( "opt-bisect" ,
cl::Hidden ,
cl::Optional ,
cl::cb< void, const std::string & > [](const std::string &IntervalStr) { if(IntervalStr=="-1") { getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}}); return; } auto Intervals= IntegerInclusiveIntervalUtils::parseIntervals(IntervalStr); if(!Intervals) { handleAllErrors(Intervals.takeError(),[&](const StringError &E) { errs()<< "Error: Invalid interval specification for -opt-bisect: "<< IntervalStr<< " ("<< E.getMessage()<< ")\n"; }); exit(1); } getOptBisector().setIntervals(std::move(*Intervals)); },
cl::desc("Run optimization passes only for the specified intervals. " "Format: '1-10,20-30,45' runs passes 1-10, 20-30, and 45, where " "index 1 is the first pass. Supply '0' to run no passes and -1 to " "run all passes.")  )
static

◆ OptBisectLimit

cl::opt< int > OptBisectLimit("opt-bisect-limit", cl::Hidden, cl::init(-1), cl::Optional, cl::cb< void, int >([](int Limit) { if(Limit==-1) getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}}); else if(Limit==0) getOptBisector().setIntervals({{0, 0}}); else if(Limit > 0) getOptBisector().setIntervals({{1, Limit}}); else llvm_unreachable(("Invalid limit for -opt-bisect-limit: "+llvm::utostr(Limit)) .c_str()); }), cl::desc( "Maximum optimization to perform (equivalent to -opt-bisect=1-N)")) ( "opt-bisect-limit" ,
cl::Hidden ,
cl::init(-1) ,
cl::Optional ,
cl::cb< void, int > [](int Limit) { if(Limit==-1) getOptBisector().setIntervals({{1, std::numeric_limits< int >::max()}}); else if(Limit==0) getOptBisector().setIntervals({{0, 0}}); else if(Limit > 0) getOptBisector().setIntervals({{1, Limit}}); else llvm_unreachable(("Invalid limit for -opt-bisect-limit: "+llvm::utostr(Limit)) .c_str()); },
cl::desc( "Maximum optimization to perform (equivalent to -opt-bisect=1-N)")  )
static

◆ OptBisectVerbose

cl::opt< bool > OptBisectVerbose("opt-bisect-verbose", cl::desc("Show verbose output when opt-bisect-limit is set"), cl::Hidden, cl::init(true), cl::Optional) ( "opt-bisect-verbose" ,
cl::desc("Show verbose output when opt-bisect-limit is set") ,
cl::Hidden ,
cl::init(true) ,
cl::Optional  )
static

◆ OptDisablePasses

cl::list< std::string > OptDisablePasses("opt-disable", cl::Hidden, cl::CommaSeparated, cl::Optional, cl::cb< void, std::string >([](const std::string &Pass) { getOptDisabler().setDisabled(Pass); }), cl::desc("Optimization pass(es) to disable (comma-separated list)")) ( "opt-disable" ,
cl::Hidden ,
cl::CommaSeparated ,
cl::Optional ,
cl::cb< void, std::string > [](const std::string &Pass) { getOptDisabler().setDisabled(Pass); },
cl::desc("Optimization pass(es) to disable (comma-separated list)")  )
static

◆ OptDisableVerbose

cl::opt< bool > OptDisableVerbose("opt-disable-enable-verbosity", cl::desc("Show verbose output when opt-disable is set"), cl::Hidden, cl::init(false), cl::Optional) ( "opt-disable-enable-verbosity" ,
cl::desc("Show verbose output when opt-disable is set") ,
cl::Hidden ,
cl::init(false) ,
cl::Optional  )
static