llvm.org GIT mirror llvm / 1e455c5
Re-commit optimization bisect support (r267022) without new pass manager support. The original commit was reverted because of a buildbot problem with LazyCallGraph::SCC handling (not related to the OptBisect handling). Differential Revision: http://reviews.llvm.org/D19172 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267231 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Kaylor 4 years ago
96 changed file(s) with 657 addition(s) and 79 deletion(s). Raw diff Collapse all Expand all
7676 /// the call graph. If the derived class implements this method, it should
7777 /// always explicitly call the implementation here.
7878 void getAnalysisUsage(AnalysisUsage &Info) const override;
79
80 protected:
81 /// Optional passes call this function to check whether the pass should be
82 /// skipped. This is the case when optimization bisect is over the limit.
83 bool skipSCC(CallGraphSCC &SCC) const;
7984 };
8085
8186 /// CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
8287 class CallGraphSCC {
88 const CallGraph &CG; // The call graph for this SCC.
8389 void *Context; // The CGPassManager object that is vending this.
8490 std::vector Nodes;
8591
8692 public:
87 CallGraphSCC(void *context) : Context(context) {}
93 CallGraphSCC(CallGraph &cg, void *context) : CG(cg), Context(context) {}
8894
8995 void initialize(CallGraphNode *const *I, CallGraphNode *const *E) {
9096 Nodes.assign(I, E);
100106 typedef std::vector::const_iterator iterator;
101107 iterator begin() const { return Nodes.begin(); }
102108 iterator end() const { return Nodes.end(); }
109
110 const CallGraph &getCallGraph() { return CG; }
103111 };
104112
105113 } // End llvm namespace
8787 virtual void deleteAnalysisLoop(Loop *L) {}
8888
8989 protected:
90 /// skipOptnoneFunction - Containing function has Attribute::OptimizeNone
91 /// and most transformation passes should skip it.
92 bool skipOptnoneFunction(const Loop *L) const;
90 /// Optional passes call this function to check whether the pass should be
91 /// skipped. This is the case when Attribute::OptimizeNone is set or when
92 /// optimization bisect is over the limit.
93 bool skipLoop(const Loop *L) const;
9394 };
9495
9596 class LPPassManager : public FunctionPass, public PMDataManager {
3131 template class SmallVectorImpl;
3232 class Function;
3333 class DebugLoc;
34 class OptBisect;
3435
3536 /// This is an important class for using LLVM in a threaded context. It
3637 /// (opaquely) owns and manages the core "global" data of LLVM's core
225226 return OptionRegistry::instance().template get();
226227 }
227228
229 /// \brief Access the object which manages optimization bisection for failure
230 /// analysis.
231 OptBisect &getOptBisect();
228232 private:
229233 LLVMContext(LLVMContext&) = delete;
230234 void operator=(LLVMContext&) = delete;
0 //===----------- llvm/IR/OptBisect.h - LLVM Bisect support -------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file declares the interface for bisecting optimizations.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_IR_OPTBISECT_H
15 #define LLVM_IR_OPTBISECT_H
16
17 namespace llvm {
18
19 class Pass;
20 class StringRef;
21 class Twine;
22
23 /// This class implements a mechanism to disable passes and individual
24 /// optimizations at compile time based on a command line option
25 /// (-opt-bisect-limit) in order to perform a bisecting search for
26 /// optimization-related problems.
27 class OptBisect {
28 public:
29 /// \brief Default constructor, initializes the OptBisect state based on the
30 /// -opt-bisect-limit command line argument.
31 ///
32 /// By default, bisection is disabled.
33 ///
34 /// Clients should not instantiate this class directly. All access should go
35 /// through LLVMContext.
36 OptBisect();
37
38 /// Checks the bisect limit to determine if the specified pass should run.
39 ///
40 /// This function will immediate return true if bisection is disabled. If the
41 /// bisect limit is set to -1, the function will print a message describing
42 /// the pass and the bisect number assigned to it and return true. Otherwise,
43 /// the function will print a message with the bisect number assigned to the
44 /// pass and indicating whether or not the pass will be run and return true if
45 /// the bisect limit has not yet been exceded or false if it has.
46 ///
47 /// Most passes should not call this routine directly. Instead, it is called
48 /// through a helper routine provided by the pass base class. For instance,
49 /// function passes should call FunctionPass::skipFunction().
50 template
51 bool shouldRunPass(const Pass *P, const UnitT &U);
52
53 /// Checks the bisect limit to determine if the optimization described by the
54 /// /p Desc argument should run.
55 ///
56 /// This function will immediate return true if bisection is disabled. If the
57 /// bisect limit is set to -1, the function will print a message with the
58 /// bisect number assigned to the optimization along with the /p Desc
59 /// description and return true. Otherwise, the function will print a message
60 /// with the bisect number assigned to the optimization and indicating whether
61 /// or not the pass will be run and return true if the bisect limit has not
62 /// yet been exceded or false if it has.
63 ///
64 /// Passes may call this function to provide more fine grained control over
65 /// individual optimizations performed by the pass. Passes which cannot be
66 /// skipped entirely (such as non-optional code generation passes) may still
67 /// call this function to control whether or not individual optional
68 /// transformations are performed.
69 bool shouldRunCase(const Twine &Desc);
70
71 private:
72 bool checkPass(const StringRef PassName, const StringRef TargetDesc);
73
74 bool BisectEnabled = false;
75 unsigned LastBisectNum = 0;
76 };
77
78 } // end namespace llvm
79
80 #endif // LLVM_IR_OPTBISECT_H
250250 explicit ModulePass(char &pid) : Pass(PT_Module, pid) {}
251251 // Force out-of-line virtual method.
252252 ~ModulePass() override;
253
254 protected:
255 /// Optional passes call this function to check whether the pass should be
256 /// skipped. This is the case when optimization bisect is over the limit.
257 bool skipModule(Module &M) const;
253258 };
254259
255260
309314 PassManagerType getPotentialPassManagerType() const override;
310315
311316 protected:
312 /// skipOptnoneFunction - This function has Attribute::OptimizeNone
313 /// and most transformation passes should skip it.
314 bool skipOptnoneFunction(const Function &F) const;
317 /// Optional passes call this function to check whether the pass should be
318 /// skipped. This is the case when Attribute::OptimizeNone is set or when
319 /// optimization bisect is over the limit.
320 bool skipFunction(const Function &F) const;
315321 };
316322
317323
358364 PassManagerType getPotentialPassManagerType() const override;
359365
360366 protected:
361 /// skipOptnoneFunction - Containing function has Attribute::OptimizeNone
362 /// and most transformation passes should skip it.
363 bool skipOptnoneFunction(const BasicBlock &BB) const;
367 /// Optional passes call this function to check whether the pass should be
368 /// skipped. This is the case when Attribute::OptimizeNone is set or when
369 /// optimization bisect is over the limit.
370 bool skipBasicBlock(const BasicBlock &BB) const;
364371 };
365372
366373 /// If the user specifies the -time-passes argument on an LLVM tool command line
2222 #include "llvm/IR/IntrinsicInst.h"
2323 #include "llvm/IR/LLVMContext.h"
2424 #include "llvm/IR/LegacyPassManagers.h"
25 #include "llvm/IR/OptBisect.h"
2526 #include "llvm/Support/CommandLine.h"
2627 #include "llvm/Support/Debug.h"
2728 #include "llvm/Support/Timer.h"
443444 // Walk the callgraph in bottom-up SCC order.
444445 scc_iterator CGI = scc_begin(&CG);
445446
446 CallGraphSCC CurSCC(&CGI);
447 CallGraphSCC CurSCC(CG, &CGI);
447448 while (!CGI.isAtEnd()) {
448449 // Copy the current SCC and increment past it so that the pass can hack
449450 // on the SCC if it wants to without invalidating our iterator.
630631 return new PrintCallGraphPass(Banner, O);
631632 }
632633
634 bool CallGraphSCCPass::skipSCC(CallGraphSCC &SCC) const {
635 return !SCC.getCallGraph().getModule()
636 .getContext()
637 .getOptBisect()
638 .shouldRunPass(this, SCC);
639 }
1515 #include "llvm/Analysis/LoopPass.h"
1616 #include "llvm/IR/IRPrintingPasses.h"
1717 #include "llvm/IR/LLVMContext.h"
18 #include "llvm/IR/OptBisect.h"
1819 #include "llvm/IR/PassManager.h"
1920 #include "llvm/Support/Debug.h"
2021 #include "llvm/Support/Timer.h"
334335 LPPM->add(this);
335336 }
336337
337 // Containing function has Attribute::OptimizeNone and transformation
338 // passes should skip it.
339 bool LoopPass::skipOptnoneFunction(const Loop *L) const {
338 bool LoopPass::skipLoop(const Loop *L) const {
340339 const Function *F = L->getHeader()->getParent();
341 if (F && F->hasFnAttribute(Attribute::OptimizeNone)) {
340 if (!F)
341 return false;
342 // Check the opt bisect limit.
343 LLVMContext &Context = F->getContext();
344 if (!Context.getOptBisect().shouldRunPass(this, *L))
345 return true;
346 // Check for the OptimizeNone attribute.
347 if (F->hasFnAttribute(Attribute::OptimizeNone)) {
342348 // FIXME: Report this to dbgs() only once per function.
343349 DEBUG(dbgs() << "Skipping pass '" << getPassName()
344350 << "' in function " << F->getName() << "\n");
8989 "Control Flow Optimizer", false, false)
9090
9191 bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
92 if (skipOptnoneFunction(*MF.getFunction()))
92 if (skipFunction(*MF.getFunction()))
9393 return false;
9494
9595 TargetPassConfig *PassConfig = &getAnalysis();
210210 }
211211
212212 bool CodeGenPrepare::runOnFunction(Function &F) {
213 if (skipOptnoneFunction(F))
213 if (skipFunction(F))
214214 return false;
215215
216216 DL = &F.getParent()->getDataLayout();
8989 }
9090
9191 bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
92 if (skipOptnoneFunction(*MF.getFunction()))
92 if (skipFunction(*MF.getFunction()))
9393 return false;
9494
9595 bool AnyChanges = false;
6262 }
6363
6464 bool LowerEmuTLS::runOnModule(Module &M) {
65 if (skipModule(M))
66 return false;
67
6568 if (!TM || !TM->Options.EmulatedTLS)
6669 return false;
6770
14291429 if (std::next(F.begin()) == F.end())
14301430 return false;
14311431
1432 if (skipOptnoneFunction(*F.getFunction()))
1432 if (skipFunction(*F.getFunction()))
14331433 return false;
14341434
14351435 MBPI = &getAnalysis();
703703 }
704704
705705 bool MachineCSE::runOnMachineFunction(MachineFunction &MF) {
706 if (skipOptnoneFunction(*MF.getFunction()))
706 if (skipFunction(*MF.getFunction()))
707707 return false;
708708
709709 TII = MF.getSubtarget().getInstrInfo();
348348 }
349349
350350 bool MachineCopyPropagation::runOnMachineFunction(MachineFunction &MF) {
351 if (skipOptnoneFunction(*MF.getFunction()))
351 if (skipFunction(*MF.getFunction()))
352352 return false;
353353
354354 Changed = false;
259259 }
260260
261261 bool MachineLICM::runOnMachineFunction(MachineFunction &MF) {
262 if (skipOptnoneFunction(*MF.getFunction()))
262 if (skipFunction(*MF.getFunction()))
263263 return false;
264264
265265 Changed = FirstInLoop = false;
323323 /// design would be to split blocks at scheduling boundaries, but LLVM has a
324324 /// general bias against block splitting purely for implementation simplicity.
325325 bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
326 if (skipOptnoneFunction(*mf.getFunction()))
326 if (skipFunction(*mf.getFunction()))
327327 return false;
328328
329329 if (EnableMachineSched.getNumOccurrences()) {
361361 }
362362
363363 bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
364 if (skipOptnoneFunction(*mf.getFunction()))
364 if (skipFunction(*mf.getFunction()))
365365 return false;
366366
367367 if (EnablePostRAMachineSched.getNumOccurrences()) {
256256 }
257257
258258 bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
259 if (skipOptnoneFunction(*MF.getFunction()))
259 if (skipFunction(*MF.getFunction()))
260260 return false;
261261
262262 DEBUG(dbgs() << "******** Machine Sinking ********\n");
6262 "Optimize machine instruction PHIs", false, false)
6363
6464 bool OptimizePHIs::runOnMachineFunction(MachineFunction &Fn) {
65 if (skipOptnoneFunction(*Fn.getFunction()))
65 if (skipFunction(*Fn.getFunction()))
6666 return false;
6767
6868 MRI = &Fn.getRegInfo();
14701470 }
14711471
14721472 bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
1473 if (skipOptnoneFunction(*MF.getFunction()))
1473 if (skipFunction(*MF.getFunction()))
14741474 return false;
14751475
14761476 DEBUG(dbgs() << "********** PEEPHOLE OPTIMIZER **********\n");
272272 }
273273
274274 bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
275 if (skipOptnoneFunction(*Fn.getFunction()))
275 if (skipFunction(*Fn.getFunction()))
276276 return false;
277277
278278 TII = Fn.getSubtarget().getInstrInfo();
656656 }
657657
658658 bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
659 if (skipOptnoneFunction(*Func.getFunction()))
659 if (skipFunction(*Func.getFunction()))
660660 return false;
661661
662662 DEBUG(dbgs() << "********** Stack Coloring **********\n"
4343 false)
4444
4545 bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) {
46 if (skipOptnoneFunction(*MF.getFunction()))
46 if (skipFunction(*MF.getFunction()))
4747 return false;
4848
4949 auto MMI = getAnalysisIfAvailable();
3838 Module.cpp
3939 ModuleSummaryIndex.cpp
4040 Operator.cpp
41 OptBisect.cpp
4142 Pass.cpp
4243 PassManager.cpp
4344 PassRegistry.cpp
324324 void LLVMContext::setDiscardValueNames(bool Discard) {
325325 pImpl->DiscardValueNames = Discard;
326326 }
327
328 OptBisect &LLVMContext::getOptBisect() {
329 return pImpl->getOptBisect();
330 }
1515 #include "llvm/IR/Attributes.h"
1616 #include "llvm/IR/DiagnosticInfo.h"
1717 #include "llvm/IR/Module.h"
18 #include "llvm/IR/OptBisect.h"
19 #include "llvm/Support/ManagedStatic.h"
1820 #include
1921 using namespace llvm;
2022
231233
232234 void CompareConstantExpr::anchor() { }
233235
236 /// Singleton instance of the OptBisect class.
237 ///
238 /// This singleton is accessed via the LLVMContext::getOptBisect() function. It
239 /// provides a mechanism to disable passes and individual optimizations at
240 /// compile time based on a command line option (-opt-bisect-limit) in order to
241 /// perform a bisecting search for optimization-related problems.
242 ///
243 /// Even if multiple LLVMContext objects are created, they will all return the
244 /// same instance of OptBisect in order to provide a single bisect count. Any
245 /// code that uses the OptBisect object should be serialized when bisection is
246 /// enabled in order to enable a consistent bisect count.
247 static ManagedStatic OptBisector;
248
249 OptBisect &LLVMContextImpl::getOptBisect() {
250 return *OptBisector;
251 }
11321132
11331133 /// Destroy the ConstantArrays if they are not used.
11341134 void dropTriviallyDeadConstantArrays();
1135
1136 /// \brief Access the object which manages optimization bisection for failure
1137 /// analysis.
1138 OptBisect &getOptBisect();
11351139 };
11361140
11371141 }
0 //===------- llvm/IR/OptBisect/Bisect.cpp - LLVM Bisect support --------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file implements support for a bisecting optimizations based on a
11 /// command line option.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/Analysis/CallGraphSCCPass.h"
16 #include "llvm/Analysis/LazyCallGraph.h"
17 #include "llvm/Analysis/LoopInfo.h"
18 #include "llvm/IR/Module.h"
19 #include "llvm/IR/OptBisect.h"
20 #include "llvm/Pass.h"
21 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/raw_ostream.h"
23
24 using namespace llvm;
25
26 static cl::opt OptBisectLimit("opt-bisect-limit", cl::Hidden,
27 cl::init(INT_MAX), cl::Optional,
28 cl::desc("Maximum optimization to perform"));
29
30 OptBisect::OptBisect() {
31 BisectEnabled = OptBisectLimit != INT_MAX;
32 }
33
34 static void printPassMessage(const StringRef &Name, int PassNum,
35 StringRef TargetDesc, bool Running) {
36 StringRef Status = Running ? "" : "NOT ";
37 errs() << "BISECT: " << Status << "running pass "
38 << "(" << PassNum << ") " << Name << " on " << TargetDesc << "\n";
39 }
40
41 static void printCaseMessage(int CaseNum, StringRef Msg, bool Running) {
42 if (Running)
43 errs() << "BISECT: running case (";
44 else
45 errs() << "BISECT: NOT running case (";
46 errs() << CaseNum << "): " << Msg << "\n";
47 }
48
49 static std::string getDescription(const Module &M) {
50 return "module (" + M.getName().str() + ")";
51 }
52
53 static std::string getDescription(const Function &F) {
54 return "function (" + F.getName().str() + ")";
55 }
56
57 static std::string getDescription(const BasicBlock &BB) {
58 return "basic block (" + BB.getName().str() + ") in function (" +
59 BB.getParent()->getName().str() + ")";
60 }
61
62 static std::string getDescription(const Loop &L) {
63 // FIXME: I'd like to be able to provide a better description here, but
64 // calling L->getHeader() would introduce a new dependency on the
65 // LLVMCore library.
66 return "loop";
67 }
68
69 static std::string getDescription(const CallGraphSCC &SCC) {
70 std::string Desc = "SCC (";
71 bool First = true;
72 for (CallGraphNode *CGN : SCC) {
73 if (First)
74 First = false;
75 else
76 Desc += ", ";
77 Function *F = CGN->getFunction();
78 if (F)
79 Desc += F->getName();
80 else
81 Desc += "<>";
82 }
83 Desc += ")";
84 return Desc;
85 }
86
87 static std::string getDescription(const LazyCallGraph::SCC &SCC) {
88 std::string Desc = "SCC (";
89 bool First = true;
90 for (LazyCallGraph::Node &CGN : SCC) {
91 if (First)
92 First = false;
93 else
94 Desc += ", ";
95 Function &F = CGN.getFunction();
96 Desc += F.getName();
97 }
98 Desc += ")";
99 return Desc;
100 }
101
102 // Force instantiations.
103 template bool OptBisect::shouldRunPass(const Pass *, const Module &);
104 template bool OptBisect::shouldRunPass(const Pass *, const Function &);
105 template bool OptBisect::shouldRunPass(const Pass *, const BasicBlock &);
106 template bool OptBisect::shouldRunPass(const Pass *, const Loop &);
107 template bool OptBisect::shouldRunPass(const Pass *, const CallGraphSCC &);
108
109 template
110 bool OptBisect::shouldRunPass(const Pass *P, const UnitT &U) {
111 if (!BisectEnabled)
112 return true;
113 return checkPass(P->getPassName(), getDescription(U));
114 }
115
116 bool OptBisect::checkPass(const StringRef PassName,
117 const StringRef TargetDesc) {
118 assert(BisectEnabled);
119
120 int CurBisectNum = ++LastBisectNum;
121 bool ShouldRun = (OptBisectLimit == -1 || CurBisectNum <= OptBisectLimit);
122 printPassMessage(PassName, CurBisectNum, TargetDesc, ShouldRun);
123 return ShouldRun;
124 }
125
126 bool OptBisect::shouldRunCase(const Twine &Msg) {
127 if (!BisectEnabled)
128 return true;
129 int CurFuelNum = ++LastBisectNum;
130 bool ShouldRun = (OptBisectLimit == -1 || CurFuelNum <= OptBisectLimit);
131 printCaseMessage(CurFuelNum, Msg.str(), ShouldRun);
132 return ShouldRun;
133 }
134
1616 #include "llvm/IR/Function.h"
1717 #include "llvm/IR/IRPrintingPasses.h"
1818 #include "llvm/IR/LegacyPassNameParser.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/IR/OptBisect.h"
1921 #include "llvm/PassRegistry.h"
2022 #include "llvm/Support/Debug.h"
2123 #include "llvm/Support/raw_ostream.h"
4244
4345 PassManagerType ModulePass::getPotentialPassManagerType() const {
4446 return PMT_ModulePassManager;
47 }
48
49 bool ModulePass::skipModule(Module &M) const {
50 return !M.getContext().getOptBisect().shouldRunPass(this, M);
4551 }
4652
4753 bool Pass::mustPreserveAnalysisID(char &AID) const {
139145 return PMT_FunctionPassManager;
140146 }
141147
142 bool FunctionPass::skipOptnoneFunction(const Function &F) const {
148 bool FunctionPass::skipFunction(const Function &F) const {
149 if (!F.getContext().getOptBisect().shouldRunPass(this, F))
150 return true;
151
143152 if (F.hasFnAttribute(Attribute::OptimizeNone)) {
144 DEBUG(dbgs() << "Skipping pass '" << getPassName()
145 << "' on function " << F.getName() << "\n");
153 DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' on function "
154 << F.getName() << "\n");
146155 return true;
147156 }
148157 return false;
167176 return false;
168177 }
169178
170 bool BasicBlockPass::skipOptnoneFunction(const BasicBlock &BB) const {
179 bool BasicBlockPass::skipBasicBlock(const BasicBlock &BB) const {
171180 const Function *F = BB.getParent();
172 if (F && F->hasFnAttribute(Attribute::OptimizeNone)) {
181 if (!F)
182 return false;
183 if (!F->getContext().getOptBisect().shouldRunPass(this, BB))
184 return true;
185 if (F->hasFnAttribute(Attribute::OptimizeNone)) {
173186 // Report this only once per function.
174187 if (&BB == &F->getEntryBlock())
175188 DEBUG(dbgs() << "Skipping pass '" << getPassName()
113113 }
114114
115115 bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) {
116 if (skipSCC(SCC))
117 return false;
118
116119 bool Changed = false, LocalChange;
117120
118121 do { // Iterate until we stop promoting from this SCC.
9595 }
9696
9797 bool ConstantMerge::runOnModule(Module &M) {
98 if (skipModule(M))
99 return false;
98100
99101 // Find all the globals that are marked "used". These cannot be merged.
100102 SmallPtrSet UsedGlobals;
157157 }
158158
159159 bool CrossDSOCFI::runOnModule(Module &M) {
160 if (skipModule(M))
161 return false;
162
160163 if (M.getModuleFlag("Cross-DSO CFI") == nullptr)
161164 return false;
162165 buildCFICheck();
10911091 }
10921092
10931093 bool DAE::runOnModule(Module &M) {
1094 if (skipModule(M))
1095 return false;
1096
10941097 bool Changed = false;
10951098
10961099 // First pass: Do a simple check to see if any functions can have their "..."
4949 }
5050
5151 bool EliminateAvailableExternally::runOnModule(Module &M) {
52 if (skipModule(M))
53 return false;
54
5255 bool Changed = false;
5356
5457 // Drop initializers of available externally global variables.
6767 : ModulePass(ID), Named(GVs.begin(), GVs.end()), deleteStuff(deleteS) {}
6868
6969 bool runOnModule(Module &M) override {
70 if (skipModule(M))
71 return false;
72
7073 // Visit the global inline asm.
7174 if (!deleteStuff)
7275 M.setModuleInlineAsm("");
10801080 Pass *llvm::createPostOrderFunctionAttrsLegacyPass() { return new PostOrderFunctionAttrsLegacyPass(); }
10811081
10821082 bool PostOrderFunctionAttrsLegacyPass::runOnSCC(CallGraphSCC &SCC) {
1083 if (skipSCC(SCC))
1084 return false;
1085
10831086 TLI = &getAnalysis().getTLI();
10841087 bool Changed = false;
10851088
11941197 }
11951198
11961199 bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) {
1200 if (skipModule(M))
1201 return false;
1202
11971203 // We only have a post-order SCC traversal (because SCCs are inherently
11981204 // discovered in post-order), so we accumulate them in a vector and then walk
11991205 // it in reverse. This is simpler than using the RPO iterator infrastructure
498498 : ModulePass(ID), Index(Index) {}
499499
500500 bool runOnModule(Module &M) override {
501 if (skipModule(M))
502 return false;
503
501504 if (SummaryFile.empty() && !Index)
502505 report_fatal_error("error: -function-import requires -summary-file or "
503506 "file from frontend\n");
7474 ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCE(); }
7575
7676 bool GlobalDCE::runOnModule(Module &M) {
77 if (skipModule(M))
78 return false;
79
7780 bool Changed = false;
7881
7982 // Remove empty functions from the global ctors list.
25272527 }
25282528
25292529 bool GlobalOpt::runOnModule(Module &M) {
2530 if (skipModule(M))
2531 return false;
2532
25302533 bool Changed = false;
25312534
25322535 auto &DL = M.getDataLayout();
5353 ModulePass *llvm::createIPConstantPropagationPass() { return new IPCP(); }
5454
5555 bool IPCP::runOnModule(Module &M) {
56 if (skipModule(M))
57 return false;
58
5659 bool Changed = false;
5760 bool LocalChange = true;
5861
978978 }
979979
980980 bool runOnModule(Module &M) override {
981 if (skipModule(M))
982 return false;
983
981984 auto &TLI = getAnalysis().getTLI();
982985 return inferAllPrototypeAttributes(M, TLI);
983986 }
355355 }
356356
357357 bool Inliner::runOnSCC(CallGraphSCC &SCC) {
358 if (skipSCC(SCC))
359 return false;
360
358361 CallGraph &CG = getAnalysis().getCallGraph();
359362 ACT = &getAnalysis();
360363 auto &TLI = getAnalysis().getTLI();
104104 }
105105
106106 bool runOnModule(Module &M) override {
107 if (skipModule(M))
108 return false;
109
107110 CallGraphWrapperPass *CGPass =
108111 getAnalysisIfAvailable();
109112 CallGraph *CG = CGPass ? &CGPass->getCallGraph() : nullptr;
8080 Pass *llvm::createLoopExtractorPass() { return new LoopExtractor(); }
8181
8282 bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &) {
83 if (skipOptnoneFunction(L))
83 if (skipLoop(L))
8484 return false;
8585
8686 // Only visit top-level loops.
248248 }
249249
250250 bool BlockExtractorPass::runOnModule(Module &M) {
251 if (skipModule(M))
252 return false;
253
251254 std::set TranslatedBlocksToNotExtract;
252255 for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) {
253256 BasicBlock *BB = BlocksToNotExtract[i];
10501050 }
10511051
10521052 bool LowerBitSets::runOnModule(Module &M) {
1053 if (skipModule(M))
1054 return false;
1055
10531056 bool Changed = buildBitSets();
10541057 Changed |= eraseBitSetMetadata();
10551058 return Changed;
15241524 }
15251525
15261526 bool MergeFunctions::runOnModule(Module &M) {
1527 if (skipModule(M))
1528 return false;
1529
15271530 bool Changed = false;
15281531
15291532 // All functions in the module, ordered by hash. Functions with a unique
148148 }
149149
150150 bool PartialInliner::runOnModule(Module& M) {
151 if (skipModule(M))
152 return false;
153
151154 std::vector worklist;
152155 worklist.reserve(M.size());
153156 for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI)
6262
6363
6464 bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
65 if (skipSCC(SCC))
66 return false;
67
6568 SmallPtrSet SCCNodes;
6669 CallGraph &CG = getAnalysis().getCallGraph();
6770 bool MadeChange = false;
6868 *PassRegistry::getPassRegistry());
6969 }
7070 bool runOnModule(Module &M) override {
71 if (skipModule(M))
72 return false;
73
7174 return stripDeadPrototypes(M);
7275 }
7376 };
228228 }
229229
230230 bool StripSymbols::runOnModule(Module &M) {
231 if (skipModule(M))
232 return false;
233
231234 bool Changed = false;
232235 Changed |= StripDebugInfo(M);
233236 if (!OnlyDebugInfo)
236239 }
237240
238241 bool StripNonDebugSymbols::runOnModule(Module &M) {
242 if (skipModule(M))
243 return false;
244
239245 return StripSymbolNames(M, true);
240246 }
241247
242248 bool StripDebugDeclare::runOnModule(Module &M) {
249 if (skipModule(M))
250 return false;
243251
244252 Function *Declare = M.getFunction("llvm.dbg.declare");
245253 std::vector DeadConstants;
285293 /// optimized away by the optimizer. This special pass removes debug info for
286294 /// such symbols.
287295 bool StripDeadDebugInfo::runOnModule(Module &M) {
296 if (skipModule(M))
297 return false;
298
288299 bool Changed = false;
289300
290301 LLVMContext &C = M.getContext();
264264 WholeProgramDevirt() : ModulePass(ID) {
265265 initializeWholeProgramDevirtPass(*PassRegistry::getPassRegistry());
266266 }
267 bool runOnModule(Module &M) { return DevirtModule(M).run(); }
267 bool runOnModule(Module &M) {
268 if (skipModule(M))
269 return false;
270
271 return DevirtModule(M).run();
272 }
268273 };
269274
270275 } // anonymous namespace
31383138 }
31393139
31403140 bool InstructionCombiningPass::runOnFunction(Function &F) {
3141 if (skipOptnoneFunction(F))
3141 if (skipFunction(F))
31423142 return false;
31433143
31443144 // Required analyses.
777777 }
778778
779779 bool PGOInstrumentationGen::runOnModule(Module &M) {
780 if (skipModule(M))
781 return false;
782
780783 createIRLevelProfileFlagVariable(M);
781784 for (auto &F : M) {
782785 if (F.isDeclaration())
800803 }
801804
802805 bool PGOInstrumentationUse::runOnModule(Module &M) {
806 if (skipModule(M))
807 return false;
808
803809 DEBUG(dbgs() << "Read in profile counters: ");
804810 auto &Ctx = M.getContext();
805811 // Read the counter array from file.
131131 if (!ModuleHasARC(M))
132132 return false;
133133
134 if (skipModule(M))
135 return false;
136
134137 // Find the llvm.global_ctors variable, as the first step in
135138 // identifying the global constructors. In theory, unnecessary autorelease
136139 // pools could occur anywhere, but in practice it's pretty rare. Global
158158 }
159159
160160 bool runOnFunction(Function& F) override {
161 if (skipOptnoneFunction(F))
161 if (skipFunction(F))
162162 return false;
163163 return aggressiveDCE(F);
164164 }
5858 false, false)
5959
6060 bool BDCE::runOnFunction(Function& F) {
61 if (skipOptnoneFunction(F))
61 if (skipFunction(F))
6262 return false;
6363 auto &DB = getAnalysis().getDemandedBits();
6464
186186
187187 /// \brief Perform the constant hoisting optimization for the given function.
188188 bool ConstantHoisting::runOnFunction(Function &Fn) {
189 if (skipOptnoneFunction(Fn))
189 if (skipFunction(Fn))
190190 return false;
191191
192192 DEBUG(dbgs() << "********** Begin Constant Hoisting **********\n");
398398 }
399399
400400 bool CorrelatedValuePropagation::runOnFunction(Function &F) {
401 if (skipOptnoneFunction(F))
401 if (skipFunction(F))
402402 return false;
403403
404404 LVI = &getAnalysis();
4141 initializeDeadInstEliminationPass(*PassRegistry::getPassRegistry());
4242 }
4343 bool runOnBasicBlock(BasicBlock &BB) override {
44 if (skipOptnoneFunction(BB))
44 if (skipBasicBlock(BB))
4545 return false;
4646 auto *TLIP = getAnalysisIfAvailable();
4747 TargetLibraryInfo *TLI = TLIP ? &TLIP->getTLI() : nullptr;
136136 }
137137
138138 bool runOnFunction(Function &F) override {
139 if (skipOptnoneFunction(F))
139 if (skipFunction(F))
140140 return false;
141141
142142 auto *TLIP = getAnalysisIfAvailable();
5757 }
5858
5959 bool runOnFunction(Function &F) override {
60 if (skipOptnoneFunction(F))
60 if (skipFunction(F))
6161 return false;
6262
6363 AA = &getAnalysis().getAAResults();
841841 }
842842
843843 bool runOnFunction(Function &F) override {
844 if (skipOptnoneFunction(F))
844 if (skipFunction(F))
845845 return false;
846846
847847 auto &TLI = getAnalysis().getTLI();
515515 }
516516
517517 bool Float2Int::runOnFunction(Function &F) {
518 if (skipOptnoneFunction(F))
518 if (skipFunction(F))
519519 return false;
520520
521521 DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n");
26732673 }
26742674
26752675 bool runOnFunction(Function &F) override {
2676 if (skipOptnoneFunction(F))
2676 if (skipFunction(F))
26772677 return false;
26782678
26792679 return Impl.runImpl(
21212121 //===----------------------------------------------------------------------===//
21222122
21232123 bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
2124 if (skipOptnoneFunction(L))
2124 if (skipLoop(L))
21252125 return false;
21262126
21272127 // If LoopSimplify form is not available, stay out of trouble. Some notes:
186186 /// runOnFunction - Top level algorithm.
187187 ///
188188 bool JumpThreading::runOnFunction(Function &F) {
189 if (skipOptnoneFunction(F))
189 if (skipFunction(F))
190190 return false;
191191
192192 DEBUG(dbgs() << "Jump threading on function '" << F.getName() << "'\n");
173173 /// times on one loop.
174174 ///
175175 bool LICM::runOnLoop(Loop *L, LPPassManager &LPM) {
176 if (skipOptnoneFunction(L))
176 if (skipLoop(L))
177177 return false;
178178
179179 Changed = false;
220220 }
221221
222222 bool LoadCombine::runOnBasicBlock(BasicBlock &BB) {
223 if (skipOptnoneFunction(BB))
223 if (skipBasicBlock(BB))
224224 return false;
225225
226226 AA = &getAnalysis().getAAResults();
118118 /// NOTE: This entire process relies pretty heavily on LoopSimplify and LCSSA
119119 /// in order to make various safety checks work.
120120 bool LoopDeletion::runOnLoop(Loop *L, LPPassManager &) {
121 if (skipOptnoneFunction(L))
121 if (skipLoop(L))
122122 return false;
123123
124124 DominatorTree &DT = getAnalysis().getDomTree();
168168 //===----------------------------------------------------------------------===//
169169
170170 bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
171 if (skipOptnoneFunction(L))
171 if (skipLoop(L))
172172 return false;
173173
174174 CurLoop = L;
6464 }
6565
6666 bool LoopInstSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
67 if (skipOptnoneFunction(L))
67 if (skipLoop(L))
6868 return false;
6969
7070 DominatorTreeWrapperPass *DTWP =
530530 }
531531
532532 bool runOnFunction(Function &F) override {
533 if (skipFunction(F))
534 return false;
535
533536 auto *LI = &getAnalysis().getLoopInfo();
534537 auto *LAA = &getAnalysis();
535538 auto *DT = &getAnalysis().getDomTree();
15351535 }
15361536
15371537 bool LoopReroll::runOnLoop(Loop *L, LPPassManager &LPM) {
1538 if (skipOptnoneFunction(L))
1538 if (skipLoop(L))
15391539 return false;
15401540
15411541 AA = &getAnalysis().getAAResults();
584584 }
585585
586586 bool runOnLoop(Loop *L, LPPassManager &LPM) override {
587 if (skipOptnoneFunction(L))
587 if (skipLoop(L))
588588 return false;
589589 Function &F = *L->getHeader()->getParent();
590590
9090 /// runOnLoop - Perform basic CFG simplifications to assist other loop passes.
9191 /// For now, this only attempts to merge blocks in the trivial case.
9292 bool LoopSimplifyCFG::runOnLoop(Loop *L, LPPassManager &) {
93 if (skipOptnoneFunction(L))
93 if (skipLoop(L))
9494 return false;
9595
9696 DominatorTree *DT = &getAnalysis().getDomTree();
50015001 }
50025002
50035003 bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager & /*LPM*/) {
5004 if (skipOptnoneFunction(L))
5004 if (skipLoop(L))
50055005 return false;
50065006
50075007 auto &IU = getAnalysis();
786786 Optional ProvidedRuntime;
787787
788788 bool runOnLoop(Loop *L, LPPassManager &) override {
789 if (skipOptnoneFunction(L))
789 if (skipLoop(L))
790790 return false;
791791
792792 Function &F = *L->getHeader()->getParent();
419419 }
420420
421421 bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
422 if (skipOptnoneFunction(L))
422 if (skipLoop(L))
423423 return false;
424424
425425 AC = &getAnalysis().getAssumptionCache(
530530 }
531531
532532 bool LoopVersioningLICM::runOnLoop(Loop *L, LPPassManager &LPM) {
533 if (skipOptnoneFunction(L))
533 if (skipLoop(L))
534534 return false;
535535 Changed = false;
536536 // Get Analysis information.
115115 initializeLowerAtomicPass(*PassRegistry::getPassRegistry());
116116 }
117117 bool runOnBasicBlock(BasicBlock &BB) override {
118 if (skipOptnoneFunction(BB))
118 if (skipBasicBlock(BB))
119119 return false;
120120 bool Changed = false;
121121 for (BasicBlock::iterator DI = BB.begin(), DE = BB.end(); DI != DE; ) {
13601360
13611361 /// This is the main transformation entry point for a function.
13621362 bool MemCpyOpt::runOnFunction(Function &F) {
1363 if (skipOptnoneFunction(F))
1363 if (skipFunction(F))
13641364 return false;
13651365
13661366 bool MadeChange = false;
559559 /// \brief Run the transformation for each function
560560 ///
561561 bool MergedLoadStoreMotion::runOnFunction(Function &F) {
562 if (skipFunction(F))
563 return false;
564
562565 auto *MDWP = getAnalysisIfAvailable();
563566 MD = MDWP ? &MDWP->getMemDep() : nullptr;
564567 AA = &getAnalysis().getAAResults();
207207 }
208208
209209 bool NaryReassociate::runOnFunction(Function &F) {
210 if (skipOptnoneFunction(F))
210 if (skipFunction(F))
211211 return false;
212212
213213 AC = &getAnalysis().getAssumptionCache(F);
22562256 }
22572257
22582258 bool Reassociate::runOnFunction(Function &F) {
2259 if (skipOptnoneFunction(F))
2259 if (skipFunction(F))
22602260 return false;
22612261
22622262 // Reassociate needs for each instruction to have its operands already
15671567 // and return true if the function was modified.
15681568 //
15691569 bool SCCP::runOnFunction(Function &F) {
1570 if (skipOptnoneFunction(F))
1570 if (skipFunction(F))
15711571 return false;
15721572
15731573 DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n");
17041704 }
17051705
17061706 bool IPSCCP::runOnModule(Module &M) {
1707 if (skipModule(M))
1708 return false;
1709
17071710 const DataLayout &DL = M.getDataLayout();
17081711 const TargetLibraryInfo *TLI =
17091712 &getAnalysis().getTLI();
42454245 initializeSROALegacyPassPass(*PassRegistry::getPassRegistry());
42464246 }
42474247 bool runOnFunction(Function &F) override {
4248 if (skipOptnoneFunction(F))
4248 if (skipFunction(F))
42494249 return false;
42504250
42514251 auto PA = Impl.runImpl(
10251025
10261026
10271027 bool SROA::runOnFunction(Function &F) {
1028 if (skipOptnoneFunction(F))
1028 if (skipFunction(F))
10291029 return false;
10301030
10311031 bool Changed = performPromotion(F);
10631063 }
10641064
10651065 bool SeparateConstOffsetFromGEP::runOnFunction(Function &F) {
1066 if (skipOptnoneFunction(F))
1066 if (skipFunction(F))
10671067 return false;
10681068
10691069 if (DisableSeparateConstOffsetFromGEP)
211211 if (PredicateFtor && !PredicateFtor(F))
212212 return false;
213213
214 if (skipOptnoneFunction(F))
214 if (skipFunction(F))
215215 return false;
216216
217217 AssumptionCache *AC =
140140 }
141141
142142 bool SpeculativeExecution::runOnFunction(Function &F) {
143 if (skipOptnoneFunction(F))
143 if (skipFunction(F))
144144 return false;
145145
146146 TTI = &getAnalysis().getTTI(F);
681681 }
682682
683683 bool StraightLineStrengthReduce::runOnFunction(Function &F) {
684 if (skipOptnoneFunction(F))
684 if (skipFunction(F))
685685 return false;
686686
687687 TTI = &getAnalysis().getTTI(F);
156156 }
157157
158158 bool TailCallElim::runOnFunction(Function &F) {
159 if (skipOptnoneFunction(F))
159 if (skipFunction(F))
160160 return false;
161161
162162 if (F.getFnAttribute("disable-tail-calls").getValueAsString() == "true")
5858 false, false)
5959
6060 bool PromotePass::runOnFunction(Function &F) {
61 if (skipFunction(F))
62 return false;
63
6164 std::vector Allocas;
6265
6366 BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
64
65 if (F.hasFnAttribute(Attribute::OptimizeNone))
66 return false;
6767
6868 bool Changed = false;
6969
396396 Instruction *I, Instruction *J);
397397
398398 bool vectorizeBB(BasicBlock &BB) {
399 if (skipOptnoneFunction(BB))
399 if (skipBasicBlock(BB))
400400 return false;
401401 if (!DT->isReachableFromEntry(&BB)) {
402402 DEBUG(dbgs() << "BBV: skipping unreachable " << BB.getName() <<
17061706 BlockFrequency ColdEntryFreq;
17071707
17081708 bool runOnFunction(Function &F) override {
1709 if (skipFunction(F))
1710 return false;
1711
17091712 SE = &getAnalysis().getSE();
17101713 LI = &getAnalysis().getLoopInfo();
17111714 TTI = &getAnalysis().getTTI(F);
33953395 }
33963396
33973397 bool runOnFunction(Function &F) override {
3398 if (skipOptnoneFunction(F))
3398 if (skipFunction(F))
33993399 return false;
34003400
34013401 SE = &getAnalysis().getSE();
0 #!/usr/bin/env python
1
2 import os
3 import sys
4 import argparse
5 import subprocess
6
7 parser = argparse.ArgumentParser()
8
9 parser.add_argument('--start', type=int, default=0)
10 parser.add_argument('--end', type=int, default=(1 << 32))
11 parser.add_argument('--optcmd', default=("opt"))
12 parser.add_argument('--filecheckcmd', default=("FileCheck"))
13 parser.add_argument('--prefix', default=("CHECK-BISECT"))
14 parser.add_argument('--test', default=(""))
15
16 args = parser.parse_args()
17
18 start = args.start
19 end = args.end
20
21 opt_command = [args.optcmd, "-O2", "-opt-bisect-limit=%(count)s", "-S", args.test]
22 check_command = [args.filecheckcmd, args.test, "--check-prefix=%s" % args.prefix]
23 last = None
24 while start != end and start != end-1:
25 count = int(round(start + (end - start)/2))
26 cmd = [x % {'count':count} for x in opt_command]
27 print("opt: " + str(cmd))
28 opt_result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
29 filecheck_result = subprocess.Popen(check_command, stdin=opt_result.stdout)
30 opt_result.stdout.close()
31 opt_result.stderr.close()
32 filecheck_result.wait()
33 if filecheck_result.returncode == 0:
34 start = count
35 else:
36 end = count
37
38 print("Last good count: %d" % start)
0 ; This file verifies the behavior of the OptBisect class, which is used to
1 ; diagnose optimization related failures. The tests check various
2 ; invocations that result in different sets of optimization passes that
3 ; are run in different ways.
4 ;
5 ; This set of tests exercises the legacy pass manager interface to the OptBisect
6 ; class. Because the exact set of optimizations that will be run may
7 ; change over time, these tests are written in a more general manner than the
8 ; corresponding tests for the new pass manager.
9 ;
10 ; Don't use NEXT checks or hard-code pass numbering so that this won't fail if
11 ; new passes are inserted.
12
13
14 ; Verify that the file can be compiled to an object file at -O3 with all
15 ; skippable passes skipped.
16
17 ; RUN: opt -O3 -opt-bisect-limit=0 < %s | llc -O3 -opt-bisect-limit=0
18
19
20 ; Verify that no skippable passes are run with -opt-bisect-limit=0.
21
22 ; RUN: opt -disable-output -disable-verify -O3 -opt-bisect-limit=0 %s 2>&1 \
23 ; RUN: | FileCheck %s --check-prefix=CHECK-SKIP-ALL
24 ; CHECK-SKIP-ALL: BISECT: NOT running pass ({{[0-9]+}})
25 ; CHECK-SKIP-ALL-NOT: BISECT: running pass ({{[0-9]+}})
26
27
28 ; Verify that we can use the opt-bisect-helper.py script (derived from
29 ; utils/bisect) to locate the optimization that inlines the call to
30 ; f2() in f3().
31
32 ; RUN: %python %S/opt-bisect-helper.py --start=0 --end=256 --optcmd=opt \
33 ; RUN: --filecheckcmd=FileCheck --test=%s \
34 ; RUN: --prefix=CHECK-BISECT-INLINE-HELPER \
35 ; RUN: | FileCheck %s --check-prefix=CHECK-BISECT-INLINE-RESULT
36 ; The helper script uses this to find the optimization that inlines the call.
37 ; CHECK-BISECT-INLINE-HELPER: call i32 @f2()
38 ; These checks verifies that the optimization was found.
39 ; CHECK-BISECT-INLINE-RESULT-NOT: Last good count: 0
40 ; CHECK-BISECT-INLINE-RESULT: Last good count: {{[0-9]+}}
41
42
43 ; Test a module pass.
44
45 ; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=-1 %s \
46 ; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEADARG
47 ; CHECK-DEADARG: BISECT: running pass ({{[0-9]+}}) Dead Argument Elimination on module
48
49 ; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=0 %s \
50 ; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-DEADARG
51 ; CHECK-NOT-DEADARG: BISECT: NOT running pass ({{[0-9]+}}) Dead Argument Elimination on module
52
53
54 ; Test an SCC pass.
55
56 ; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=-1 %s \
57 ; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
58 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<>)
59 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g)
60 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1)
61 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2)
62 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3)
63 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<>)
64
65 ; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=0 %s \
66 ; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
67 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<>)
68 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g)
69 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1)
70 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2)
71 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3)
72 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<>)
73
74
75 ; Test a function pass.
76
77 ; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=-1 \
78 ; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-EARLY-CSE
79 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f1)
80 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f2)
81 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f3)
82
83 ; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=0 %s \
84 ; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-EARLY-CSE
85 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f1)
86 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f2)
87 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f3)
88
89
90 ; Test a loop pass.
91
92 ; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=-1 \
93 ; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-LOOP-REDUCE
94 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
95 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
96 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
97 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
98 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
99
100 ; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=0 \
101 ; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-LOOP-REDUCE
102 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
103 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
104 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
105 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
106 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
107
108
109 declare i32 @g()
110
111 define void @f1() {
112 entry:
113 br label %loop.0
114 loop.0:
115 br i1 undef, label %loop.0.0, label %loop.1
116 loop.0.0:
117 br i1 undef, label %loop.0.0, label %loop.0.1
118 loop.0.1:
119 br i1 undef, label %loop.0.1, label %loop.0
120 loop.1:
121 br i1 undef, label %loop.1, label %loop.1.bb1
122 loop.1.bb1:
123 br i1 undef, label %loop.1, label %loop.1.bb2
124 loop.1.bb2:
125 br i1 undef, label %end, label %loop.1.0
126 loop.1.0:
127 br i1 undef, label %loop.1.0, label %loop.1
128 end:
129 ret void
130 }
131
132 define i32 @f2() {
133 entry:
134 ret i32 0
135 }
136
137 define i32 @f3() {
138 entry:
139 %temp = call i32 @g()
140 %icmp = icmp ugt i32 %temp, 2
141 br i1 %icmp, label %bb.true, label %bb.false
142 bb.true:
143 %temp2 = call i32 @f2()
144 ret i32 %temp2
145 bb.false:
146 ret i32 0
147 }