This is a new patch for the optimization bisect feature, which will allow optimizations to be selectively disabled at compile time in order to track down test failures that are caused by incorrect optimizations.
My previous patch (D18576) proposed adding new methods to the Pass base class (and various templates for the new pass manager) to allow the OptBisect object to query whether or not a pass is skippable with the bisection being initiated from within the various pass managers. During the review, an alternate approach was suggested, to be based on the function optnone handling, whereby each skippable pass would opt in to the bisection process at the start of its run routine. This patch implements that alternate approach.
For function, loop and basic block passes, I am replacing the existing calls to "skipOptnoneFunction()" with a call to a new function that checks the opt bisect limit as well as the optnone attribute. For the most part I treated the presence or absence of an existing call to skipOptnoneFunction() as an indication of whether or not the pass could be skipped. There were three passes that were not calling skipOptnoneFunction() that seemed to me as if they should, so I added the call. Those passes were:
MergedLoadStoreMotion
LoopVectorize
LoopLoadElimination
There was no equivalent mechanism for module passes and SCC passes. For these passes, I attempted to discern whether or not the pass was skippable and added calls to the appropriate function to check the bisect limit. The passes I chose to treat as skippable can be seen in the code changes in this review. Those that I determined were not skippable do not show up here, so it seems worth noting the module and SCC passes I considered to be non-skippable. Here's the list:
AMDGPUAnnotateKernelFeatures
AMDGPUOpenCLImageTypeLoweringPass
DOTGraphTraitsModuleViewer
DOTGraphTraitsModulePrinter
CallGraphWrapperPass
CGPassManager
GlobalsAAWrapperPass
ModuleDebugInfoPrinter
ModuleSummaryIndexWrapperPass
WriteBitcodePass
PrintModulePassWrapper
FPPassManager
MPPassManager
CppWriter
AddressSanitizerModule
DataFlowSanitizer
GCOVProfiler
InstrProfiling
SanitizerCoverageModule
NVPTXAssignValidGlobalNames
RewriteStatepointsForGC
MetaRenamer
RewriteSymbols
SampleProfileLoader
ForceFunctionAttrsLegacyPass
PrintCallGraphPass
CallGraphSCCPassPrinter
There was also no optnone equivalent for region passes. However, since the only region passes in the LLVM code base (StructuralizeCFG, PrinRegionPass and RegionPassPrinter) would have been non-skippable, it seemed best to omit any handling for region passes at this time. If anyone has region passes which should be included in the bisection, it will be a simple matter to add such support.
It think we should add a getCallGraph() method because that is what we are storing (or alternative only store an LLVMContext& in the class). We may or may not keep getContext() as a convenience method.