llvm.org GIT mirror llvm / 85a14f0
Temporarily Revert "[New PM] Introducing PassInstrumentation framework" as it was causing failures in the asan buildbot. This reverts commit r342597. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342616 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 1 year, 2 days ago
22 changed file(s) with 48 addition(s) and 733 deletion(s). Raw diff Collapse all Expand all
362362 CGSCCUpdateResult UR = {RCWorklist, CWorklist, InvalidRefSCCSet,
363363 InvalidSCCSet, nullptr, nullptr,
364364 InlinedInternalEdges};
365
366 // Request PassInstrumentation from analysis manager, will use it to run
367 // instrumenting callbacks for the passes later.
368 PassInstrumentation PI = AM.getResult(M);
369365
370366 PreservedAnalyses PA = PreservedAnalyses::all();
371367 CG.buildRefSCCs();
431427
432428 UR.UpdatedRC = nullptr;
433429 UR.UpdatedC = nullptr;
434
435 // Check the PassInstrumentation's BeforePass callbacks before
436 // running the pass, skip its execution completely if asked to
437 // (callback returns false).
438 if (!PI.runBeforePass(Pass, *C))
439 continue;
440
441430 PreservedAnalyses PassPA = Pass.run(*C, CGAM, CG, UR);
442
443 PI.runAfterPass(Pass, *C);
444431
445432 // Update the SCC and RefSCC if necessary.
446433 C = UR.UpdatedC ? UR.UpdatedC : C;
627614 if (CG.lookupSCC(*N) != CurrentC)
628615 continue;
629616
630 Function &F = N->getFunction();
631
632 PassInstrumentation PI = FAM.getResult(F);
633 if (!PI.runBeforePass(Pass, F))
634 continue;
635
636 PreservedAnalyses PassPA = Pass.run(F, FAM);
637
638 PI.runAfterPass(Pass, F);
617 PreservedAnalyses PassPA = Pass.run(N->getFunction(), FAM);
639618
640619 // We know that the function pass couldn't have invalidated any other
641620 // function's analyses (that's the contract of a function pass), so
642621 // directly handle the function analysis manager's invalidation here.
643 FAM.invalidate(F, PassPA);
622 FAM.invalidate(N->getFunction(), PassPA);
644623
645624 // Then intersect the preserved set so that invalidation of module
646625 // analyses will eventually occur when the module pass completes.
710689 PreservedAnalyses run(LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM,
711690 LazyCallGraph &CG, CGSCCUpdateResult &UR) {
712691 PreservedAnalyses PA = PreservedAnalyses::all();
713 PassInstrumentation PI =
714 AM.getResult(InitialC, CG);
715692
716693 // The SCC may be refined while we are running passes over it, so set up
717694 // a pointer that we can update.
755732 auto CallCounts = ScanSCC(*C, CallHandles);
756733
757734 for (int Iteration = 0;; ++Iteration) {
758
759 if (!PI.runBeforePass(Pass, *C))
760 continue;
761
762735 PreservedAnalyses PassPA = Pass.run(*C, AM, CG, UR);
763
764 PI.runAfterPass(Pass, *C);
765736
766737 // If the SCC structure has changed, bail immediately and let the outer
767738 // CGSCC layer handle any iteration to reflect the refined structure.
+0
-150
include/llvm/IR/PassInstrumentation.h less more
None //===- llvm/IR/PassInstrumentation.h ----------------------*- C++ -*-===//
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 /// \file
9 ///
10 /// This file defines the Pass Instrumentation classes that provide
11 /// instrumentation points into the pass execution by PassManager.
12 ///
13 /// There are two main classes:
14 /// - PassInstrumentation provides a set of instrumentation points for
15 /// pass managers to call on.
16 ///
17 /// - PassInstrumentationCallbacks registers callbacks and provides access
18 /// to them for PassInstrumentation.
19 ///
20 /// PassInstrumentation object is being used as a result of
21 /// PassInstrumentationAnalysis (so it is intended to be easily copyable).
22 ///
23 /// Intended scheme of use for Pass Instrumentation is as follows:
24 /// - register instrumentation callbacks in PassInstrumentationCallbacks
25 /// instance. PassBuilder provides helper for that.
26 ///
27 /// - register PassInstrumentationAnalysis with all the PassManagers.
28 /// PassBuilder handles that automatically when registering analyses.
29 ///
30 /// - Pass Manager requests PassInstrumentationAnalysis from analysis manager
31 /// and gets PassInstrumentation as its result.
32 ///
33 /// - Pass Manager invokes PassInstrumentation entry points appropriately,
34 /// passing StringRef identification ("name") of the pass currently being
35 /// executed and IRUnit it works on. There can be different schemes of
36 /// providing names in future, currently it is just a name() of the pass.
37 ///
38 /// - PassInstrumentation wraps address of IRUnit into llvm::Any and passes
39 /// control to all the registered callbacks. Note that we specifically wrap
40 /// 'const IRUnitT*' so as to avoid any accidental changes to IR in
41 /// instrumenting callbacks.
42 ///
43 /// - Some instrumentation points (BeforePass) allow to control execution
44 /// of a pass. For those callbacks returning false means pass will not be
45 /// executed.
46 ///
47 /// TODO: currently there is no way for a pass to opt-out of execution control
48 /// (e.g. become unskippable). PassManager is the only entity that determines
49 /// how pass instrumentation affects pass execution.
50 ///
51 //===----------------------------------------------------------------------===//
52
53 #ifndef LLVM_IR_PASSINSTRUMENTATION_H
54 #define LLVM_IR_PASSINSTRUMENTATION_H
55
56 #include "llvm/ADT/Any.h"
57 #include "llvm/ADT/FunctionExtras.h"
58 #include "llvm/ADT/SmallVector.h"
59 #include "llvm/Support/TypeName.h"
60 #include
61
62 namespace llvm {
63
64 class PreservedAnalyses;
65
66 /// This class manages callbacks registration, as well as provides a way for
67 /// PassInstrumentation to pass control to the registered callbacks.
68 class PassInstrumentationCallbacks {
69 public:
70 // Before/After Pass callbacks accept IRUnits, so they need to take them
71 // as pointers, wrapped with llvm::Any
72 using BeforePassFunc = bool(StringRef, Any);
73 using AfterPassFunc = void(StringRef, Any);
74 using BeforeAnalysisFunc = void(StringRef, Any);
75 using AfterAnalysisFunc = void(StringRef, Any);
76
77 public:
78 PassInstrumentationCallbacks() {}
79
80 /// Copying PassInstrumentationCallbacks is not intended.
81 PassInstrumentationCallbacks(const PassInstrumentationCallbacks &) = delete;
82 void operator=(const PassInstrumentationCallbacks &) = delete;
83
84 template void registerBeforePassCallback(CallableT C) {
85 BeforePassCallbacks.emplace_back(std::move(C));
86 }
87
88 template void registerAfterPassCallback(CallableT C) {
89 AfterPassCallbacks.emplace_back(std::move(C));
90 }
91
92 private:
93 friend class PassInstrumentation;
94
95 SmallVector, 4> BeforePassCallbacks;
96 SmallVector, 4> AfterPassCallbacks;
97 };
98
99 /// This class provides instrumentation entry points for the Pass Manager,
100 /// doing calls to callbacks registered in PassInstrumentationCallbacks.
101 class PassInstrumentation {
102 PassInstrumentationCallbacks *Callbacks;
103
104 public:
105 /// Callbacks object is not owned by PassInstrumentation, its life-time
106 /// should at least match the life-time of corresponding
107 /// PassInstrumentationAnalysis (which usually is till the end of current
108 /// compilation).
109 PassInstrumentation(PassInstrumentationCallbacks *CB = nullptr)
110 : Callbacks(CB) {}
111
112 /// BeforePass instrumentation point - takes \p Pass instance to be executed
113 /// and constant reference to IR it operates on. \Returns true if pass is
114 /// allowed to be executed.
115 template
116 bool runBeforePass(const PassT &Pass, const IRUnitT &IR) const {
117 if (!Callbacks)
118 return true;
119
120 bool ShouldRun = true;
121 for (auto &C : Callbacks->BeforePassCallbacks)
122 ShouldRun &= C(Pass.name(), llvm::Any(&IR));
123 return ShouldRun;
124 }
125
126 /// AfterPass instrumentation point - takes \p Pass instance that has
127 /// just been executed and constant reference to IR it operates on.
128 template
129 void runAfterPass(const PassT &Pass, const IRUnitT &IR) const {
130 if (Callbacks)
131 for (auto &C : Callbacks->AfterPassCallbacks)
132 C(Pass.name(), llvm::Any(&IR));
133 }
134
135 /// Handle invalidation from the pass manager when PassInstrumentation
136 /// is used as the result of PassInstrumentationAnalysis.
137 ///
138 /// On attempt to invalidate just return false. There is nothing to become
139 /// invalid here.
140 template
141 bool invalidate(IRUnitT &, const class llvm::PreservedAnalyses &,
142 ExtraArgsT...) {
143 return false;
144 }
145 };
146
147 } // namespace llvm
148
149 #endif
4343 #include "llvm/ADT/TinyPtrVector.h"
4444 #include "llvm/IR/Function.h"
4545 #include "llvm/IR/Module.h"
46 #include "llvm/IR/PassInstrumentation.h"
4746 #include "llvm/IR/PassManagerInternal.h"
4847 #include "llvm/Support/Debug.h"
4948 #include "llvm/Support/TypeName.h"
402401 }
403402 };
404403
405 namespace detail {
406
407 /// Actual unpacker of extra arguments in getAnalysisResult,
408 /// passes only those tuple arguments that are mentioned in index_sequence.
409 template
410 typename... ArgTs, size_t... Ns>
411 typename PassT::Result
412 getAnalysisResultUnpackTuple(AnalysisManagerT &AM, IRUnitT &IR,
413 std::tuple Args,
414 llvm::index_sequence) {
415 (void)Args;
416 return AM.template getResult(IR, std::get(Args)...);
417 }
418
419 /// Helper for *partial* unpacking of extra arguments in getAnalysisResult.
420 ///
421 /// Arguments passed in tuple come from PassManager, so they might have extra
422 /// arguments after those AnalysisManager's ExtraArgTs ones that we need to
423 /// pass to getResult.
424 template
425 typename... MainArgTs>
426 typename PassT::Result
427 getAnalysisResult(AnalysisManager &AM, IRUnitT &IR,
428 std::tuple Args) {
429 return (getAnalysisResultUnpackTuple<
430 PassT, IRUnitT>)(AM, IR, Args,
431 llvm::index_sequence_for{});
432 }
433
434 } // namespace detail
435
436 // Forward declare the pass instrumentation analysis explicitly queried in
437 // generic PassManager code.
438 // FIXME: figure out a way to move PassInstrumentationAnalysis into its own
439 // header.
440 class PassInstrumentationAnalysis;
441
442404 /// Manages a sequence of passes over a particular unit of IR.
443405 ///
444406 /// A pass manager contains a sequence of passes to run over a particular unit
482444 ExtraArgTs... ExtraArgs) {
483445 PreservedAnalyses PA = PreservedAnalyses::all();
484446
485 // Request PassInstrumentation from analysis manager, will use it to run
486 // instrumenting callbacks for the passes later.
487 // Here we use std::tuple wrapper over getResult which helps to extract
488 // AnalysisManager's arguments out of the whole ExtraArgs set.
489 PassInstrumentation PI =
490 detail::getAnalysisResult(
491 AM, IR, std::tuple(ExtraArgs...));
492
493447 if (DebugLogging)
494448 dbgs() << "Starting " << getTypeName() << " pass manager run.\n";
495449
496450 for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) {
497 auto *P = Passes[Idx].get();
498451 if (DebugLogging)
499 dbgs() << "Running pass: " << P->name() << " on " << IR.getName()
500 << "\n";
501
502 // Check the PassInstrumentation's BeforePass callbacks before running the
503 // pass, skip its execution completely if asked to (callback returns
504 // false).
505 if (!PI.runBeforePass(*P, IR))
506 continue;
507
508 PreservedAnalyses PassPA = P->run(IR, AM, ExtraArgs...);
509
510 // Call onto PassInstrumentation's AfterPass callbacks immediately after
511 // running the pass.
512 PI.runAfterPass(*P, IR);
452 dbgs() << "Running pass: " << Passes[Idx]->name() << " on "
453 << IR.getName() << "\n";
454
455 PreservedAnalyses PassPA = Passes[Idx]->run(IR, AM, ExtraArgs...);
513456
514457 // Update the analysis manager as each pass runs and potentially
515458 // invalidates analyses.
565508
566509 /// Convenience typedef for a pass manager over functions.
567510 using FunctionPassManager = PassManager;
568
569 /// Pseudo-analysis pass that exposes the \c PassInstrumentation to pass
570 /// managers. Goes before AnalysisManager definition to provide its
571 /// internals (e.g PassInstrumentationAnalysis::ID) for use there if needed.
572 /// FIXME: figure out a way to move PassInstrumentationAnalysis into its own
573 /// header.
574 class PassInstrumentationAnalysis
575 : public AnalysisInfoMixin {
576 friend AnalysisInfoMixin;
577 static AnalysisKey Key;
578
579 PassInstrumentationCallbacks *Callbacks;
580
581 public:
582 /// PassInstrumentationCallbacks object is shared, owned by something else,
583 /// not this analysis.
584 PassInstrumentationAnalysis(PassInstrumentationCallbacks *Callbacks = nullptr)
585 : Callbacks(Callbacks) {}
586
587 using Result = PassInstrumentation;
588
589 template
590 Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
591 return PassInstrumentation(Callbacks);
592 }
593 };
594511
595512 /// A container for analyses that lazily runs them and caches their
596513 /// results.
12741191 FunctionAnalysisManager &FAM =
12751192 AM.getResult(M).getManager();
12761193
1277 // Request PassInstrumentation from analysis manager, will use it to run
1278 // instrumenting callbacks for the passes later.
1279 PassInstrumentation PI = AM.getResult(M);
1280
12811194 PreservedAnalyses PA = PreservedAnalyses::all();
12821195 for (Function &F : M) {
12831196 if (F.isDeclaration())
12841197 continue;
12851198
1286 // Check the PassInstrumentation's BeforePass callbacks before running the
1287 // pass, skip its execution completely if asked to (callback returns
1288 // false).
1289 if (!PI.runBeforePass(Pass, F))
1290 continue;
12911199 PreservedAnalyses PassPA = Pass.run(F, FAM);
1292
1293 PI.runAfterPass(Pass, F);
12941200
12951201 // We know that the function pass couldn't have invalidated any other
12961202 // function's analyses (that's the contract of a function pass), so
13951301 RepeatedPass(int Count, PassT P) : Count(Count), P(std::move(P)) {}
13961302
13971303 template
1398 PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, Ts &&... Args) {
1399
1400 // Request PassInstrumentation from analysis manager, will use it to run
1401 // instrumenting callbacks for the passes later.
1402 // Here we use std::tuple wrapper over getResult which helps to extract
1403 // AnalysisManager's arguments out of the whole Args set.
1404 PassInstrumentation PI =
1405 detail::getAnalysisResult(
1406 AM, IR, std::tuple(Args...));
1407
1304 PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT &AM, Ts &&... Args) {
14081305 auto PA = PreservedAnalyses::all();
1409 for (int i = 0; i < Count; ++i) {
1410 // Check the PassInstrumentation's BeforePass callbacks before running the
1411 // pass, skip its execution completely if asked to (callback returns
1412 // false).
1413 if (!PI.runBeforePass(P, IR))
1414 continue;
1415 PA.intersect(P.run(IR, AM, std::forward(Args)...));
1416 PI.runAfterPass(P, IR);
1417 }
1306 for (int i = 0; i < Count; ++i)
1307 PA.intersect(P.run(Arg, AM, std::forward(Args)...));
14181308 return PA;
14191309 }
14201310
5757 class PassBuilder {
5858 TargetMachine *TM;
5959 Optional PGOOpt;
60 PassInstrumentationCallbacks *PIC;
6160
6261 public:
6362 /// A struct to capture parsed pass pipeline names.
172171 };
173172
174173 explicit PassBuilder(TargetMachine *TM = nullptr,
175 Optional PGOOpt = None,
176 PassInstrumentationCallbacks *PIC = nullptr)
177 : TM(TM), PGOOpt(PGOOpt), PIC(PIC) {}
174 Optional PGOOpt = None)
175 : TM(TM), PGOOpt(PGOOpt) {}
178176
179177 /// Cross register the analysis managers through their proxies.
180178 ///
275275 // pass pipeline to put loops into their canonical form. Note that we can
276276 // directly build up function analyses after this as the function pass
277277 // manager handles all the invalidation at that layer.
278 PassInstrumentation PI = AM.getResult(F);
279
280 PreservedAnalyses PA = PreservedAnalyses::all();
281 // Check the PassInstrumentation's BeforePass callbacks before running the
282 // canonicalization pipeline.
283 if (PI.runBeforePass(LoopCanonicalizationFPM, F)) {
284 PA = LoopCanonicalizationFPM.run(F, AM);
285 PI.runAfterPass(LoopCanonicalizationFPM, F);
286 }
278 PreservedAnalyses PA = LoopCanonicalizationFPM.run(F, AM);
287279
288280 // Get the loop structure for this function
289281 LoopInfo &LI = AM.getResult(F);
344336 assert(L->isRecursivelyLCSSAForm(LAR.DT, LI) &&
345337 "Loops must remain in LCSSA form!");
346338 #endif
347 // Check the PassInstrumentation's BeforePass callbacks before running the
348 // pass, skip its execution completely if asked to (callback returns
349 // false).
350 if (!PI.runBeforePass(Pass, *L))
351 continue;
339
352340 PreservedAnalyses PassPA = Pass.run(*L, LAM, LAR, Updater);
353
354 PI.runAfterPass(Pass, *L);
355
356341 // FIXME: We should verify the set of analyses relevant to Loop passes
357342 // are preserved.
358343
5353 CGSCCUpdateResult &>::run(LazyCallGraph::SCC &InitialC,
5454 CGSCCAnalysisManager &AM,
5555 LazyCallGraph &G, CGSCCUpdateResult &UR) {
56 // Request PassInstrumentation from analysis manager, will use it to run
57 // instrumenting callbacks for the passes later.
58 PassInstrumentation PI =
59 AM.getResult(InitialC, G);
60
6156 PreservedAnalyses PA = PreservedAnalyses::all();
6257
6358 if (DebugLogging)
7166 if (DebugLogging)
7267 dbgs() << "Running pass: " << Pass->name() << " on " << *C << "\n";
7368
74 // Check the PassInstrumentation's BeforePass callbacks before running the
75 // pass, skip its execution completely if asked to (callback returns false).
76 if (!PI.runBeforePass(*Pass, *C))
77 continue;
78
7969 PreservedAnalyses PassPA = Pass->run(*C, AM, G, UR);
80
81 PI.runAfterPass(*Pass, *C);
8270
8371 // Update the SCC if necessary.
8472 C = UR.UpdatedC ? UR.UpdatedC : C;
7272 FPM.addPass(DCEPass());
7373 FunctionAnalysisManager FAM;
7474 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
75 FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
7675 FPM.run(F, FAM);
7776 }
7877
4141 Operator.cpp
4242 OptBisect.cpp
4343 Pass.cpp
44 PassInstrumentation.cpp
4544 PassManager.cpp
4645 PassRegistry.cpp
4746 PassTimingInfo.cpp
+0
-22
lib/IR/PassInstrumentation.cpp less more
None //===- PassInstrumentation.cpp - Pass Instrumentation interface -*- C++ -*-===//
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 /// \file
9 ///
10 /// This file provides the implementation of PassInstrumentation class.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/IR/PassInstrumentation.h"
15 #include "llvm/IR/PassManager.h"
16
17 namespace llvm {
18
19 AnalysisKey PassInstrumentationAnalysis::Key;
20
21 } // namespace llvm
2525 MODULE_ANALYSIS("profile-summary", ProfileSummaryAnalysis())
2626 MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
2727 MODULE_ANALYSIS("verify", VerifierAnalysis())
28 MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
2928
3029 #ifndef MODULE_ALIAS_ANALYSIS
3130 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
8483 #endif
8584 CGSCC_ANALYSIS("no-op-cgscc", NoOpCGSCCAnalysis())
8685 CGSCC_ANALYSIS("fam-proxy", FunctionAnalysisManagerCGSCCProxy())
87 CGSCC_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
8886 #undef CGSCC_ANALYSIS
8987
9088 #ifndef CGSCC_PASS
122120 FUNCTION_ANALYSIS("targetir",
123121 TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis())
124122 FUNCTION_ANALYSIS("verify", VerifierAnalysis())
125 FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
126123
127124 #ifndef FUNCTION_ALIAS_ANALYSIS
128125 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
228225 LOOP_ANALYSIS("no-op-loop", NoOpLoopAnalysis())
229226 LOOP_ANALYSIS("access-info", LoopAccessAnalysis())
230227 LOOP_ANALYSIS("ivusers", IVUsersAnalysis())
231 LOOP_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
232228 #undef LOOP_ANALYSIS
233229
234230 #ifndef LOOP_PASS
2929 if (DebugLogging)
3030 dbgs() << "Starting Loop pass manager run.\n";
3131
32 // Request PassInstrumentation from analysis manager, will use it to run
33 // instrumenting callbacks for the passes later.
34 PassInstrumentation PI = AM.getResult(L, AR);
3532 for (auto &Pass : Passes) {
3633 if (DebugLogging)
3734 dbgs() << "Running pass: " << Pass->name() << " on " << L;
3835
39 // Check the PassInstrumentation's BeforePass callbacks before running the
40 // pass, skip its execution completely if asked to (callback returns false).
41 if (!PI.runBeforePass(*Pass, L))
42 continue;
43
4436 PreservedAnalyses PassPA = Pass->run(L, AM, AR, U);
45
46 PI.runAfterPass(*Pass, L);
4737
4838 // If the loop was deleted, abort the run and return to the outer walk.
4939 if (U.skipCurrentLoop()) {
7272 ; CHECK-LOOP-INV-NEXT: Running analysis: TargetIRAnalysis
7373 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
7474 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
75 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
7675 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
7776 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
7877 ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis
9089 ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
9190 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
9291 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
93 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
9492 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
9593 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
9694 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run.
109107 ; CHECK-SCEV-INV-NEXT: Running analysis: TargetIRAnalysis
110108 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
111109 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
112 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
113110 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
114111 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
115112 ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis
125122 ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
126123 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
127124 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
128 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
129125 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
130126 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
131127 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run.
156152 ; CHECK-LOOP-INV-NEXT: Running analysis: TargetIRAnalysis
157153 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
158154 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
159 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
160 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
161 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
162 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
163 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
155 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
156 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
157 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
164158 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
165159 ; CHECK-LOOP-INV: Finished {{.*}}Loop pass manager run.
166160 ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis
179173 ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
180174 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
181175 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
182 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
183 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
184 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
185 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
186 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
176 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
177 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
178 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
187179 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
188180 ; CHECK-LOOP-INV: Finished {{.*}}Loop pass manager run.
189181 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run.
202194 ; CHECK-SCEV-INV-NEXT: Running analysis: TargetIRAnalysis
203195 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
204196 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
205 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
206 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
207 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
208 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
209 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
197 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
198 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
199 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
210200 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
211201 ; CHECK-SCEV-INV: Finished {{.*}}Loop pass manager run.
212202 ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis
223213 ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
224214 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
225215 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
226 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
227 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
228 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
229 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
230 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
216 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
217 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
218 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
231219 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
232220 ; CHECK-SCEV-INV: Finished {{.*}}Loop pass manager run.
233221 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run.
265253 ; CHECK-LOOP-INV-NEXT: Running analysis: TargetIRAnalysis
266254 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
267255 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
268 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
269256 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
270257 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
271258 ; CHECK-LOOP-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}LoopAnalysis
283270 ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
284271 ; CHECK-LOOP-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
285272 ; CHECK-LOOP-INV-NEXT: Starting {{.*}}Loop pass manager run.
286 ; CHECK-LOOP-INV-NEXT: Running analysis: PassInstrumentationAnalysis
287273 ; CHECK-LOOP-INV-NEXT: Running pass: NoOpLoopPass
288274 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Loop pass manager run.
289275 ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run.
302288 ; CHECK-SCEV-INV-NEXT: Running analysis: TargetIRAnalysis
303289 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
304290 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
305 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
306291 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
307292 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
308293 ; CHECK-SCEV-INV-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis
318303 ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis
319304 ; CHECK-SCEV-INV-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
320305 ; CHECK-SCEV-INV-NEXT: Starting {{.*}}Loop pass manager run.
321 ; CHECK-SCEV-INV-NEXT: Running analysis: PassInstrumentationAnalysis
322306 ; CHECK-SCEV-INV-NEXT: Running pass: NoOpLoopPass
323307 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Loop pass manager run.
324308 ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run.
337321 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: TargetIRAnalysis
338322 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Loop
339323 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Starting {{.*}}Loop pass manager run.
340 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: PassInstrumentationAnalysis
341324 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: NoOpLoopPass
342325 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: LoopDeletionPass
343326 ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Clearing all analysis results for:
2323 ; CHECK-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(FunctionAnalysisManager|AnalysisManager<.*Function.*>).*}},{{.*}}Module>
2424 ; CHECK-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis
2525 ; CHECK-CGSCC-PASS-NEXT: Running analysis: TargetLibraryAnalysis
26 ; CHECK-CGSCC-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
2726 ; CHECK-CGSCC-PASS-NEXT: Starting CGSCC pass manager run
2827 ; CHECK-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass
2928 ; CHECK-CGSCC-PASS-NEXT: Finished CGSCC pass manager run
3837 ; CHECK-FUNCTION-PASS: Starting llvm::Module pass manager run
3938 ; CHECK-FUNCTION-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor
4039 ; CHECK-FUNCTION-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
41 ; CHECK-FUNCTION-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
4240 ; CHECK-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run
4341 ; CHECK-FUNCTION-PASS-NEXT: Running pass: NoOpFunctionPass
4442 ; CHECK-FUNCTION-PASS-NEXT: Finished llvm::Function pass manager run
409407 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(FunctionAnalysisManager|AnalysisManager<.*Function.*>).*}},{{.*}}Module>
410408 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis
411409 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: TargetLibraryAnalysis
412 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
413410 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Starting CGSCC pass manager run
414411 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: RepeatedPass
415412 ; CHECK-REPEAT-CGSCC-PASS-NEXT: Starting CGSCC pass manager run
430427 ; CHECK-REPEAT-FUNCTION-PASS: Starting llvm::Module pass manager run
431428 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor
432429 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
433 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
434430 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run
435431 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: RepeatedPass
436432 ; CHECK-REPEAT-FUNCTION-PASS-NEXT: Starting llvm::Function pass manager run
451447 ; CHECK-REPEAT-LOOP-PASS: Starting llvm::Module pass manager run
452448 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: ModuleToFunctionPassAdaptor
453449 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
454 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
455450 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Function pass manager run
456451 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: FunctionToLoopPassAdaptor
457452 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Function pass manager run
468463 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetIRAnalysis
469464 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
470465 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting Loop pass manager run
471 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: PassInstrumentationAnalysis
472466 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: RepeatedPass
473467 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting Loop pass manager run
474468 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: NoOpLoopPass
6666 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \
6767 ; RUN: --check-prefix=CHECK-EP-PIPELINE-START
6868
69 ; CHECK-O: Running analysis: PassInstrumentationAnalysis
70 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
69 ; CHECK-O: Starting llvm::Module pass manager run.
7170 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
7271 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
7372 ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
7877 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
7978 ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
8079 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
81 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
8280 ; CHECK-O-NEXT: Starting llvm::Function pass manager run.
8381 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass
8482 ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis
111109 ; CHECK-O-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor<{{.*}}LazyCallGraph{{.*}}>
112110 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
113111 ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis
114 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
115112 ; CHECK-O-NEXT: Starting CGSCC pass manager run.
116113 ; CHECK-O-NEXT: Running pass: InlinerPass
117114 ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph{{.*}}>
151148 ; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis
152149 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
153150 ; CHECK-O-NEXT: Starting Loop pass manager run.
154 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
155151 ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass
156152 ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass
157153 ; CHECK-O-NEXT: Running pass: LoopRotatePass
2222 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O2 \
2323 ; RUN: --check-prefix=CHECK-O3 --check-prefix=CHECK-EP-Peephole
2424
25 ; CHECK-O: Running analysis: PassInstrumentationAnalysis
26 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
25 ; CHECK-O: Starting llvm::Module pass manager run.
2726 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module
2827 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
2928 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
3231 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
3332 ; CHECK-O2-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
3433 ; CHECK-O2-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}Module
35 ; CHECK-O2-NEXT: Running analysis: PassInstrumentationAnalysis
3634 ; CHECK-O2-NEXT: Starting llvm::Function pass manager run.
3735 ; CHECK-O2-NEXT: Running pass: CallSiteSplittingPass on foo
3836 ; CHECK-O2-NEXT: Running analysis: TargetLibraryAnalysis on foo
4646 ; RUN: -passes='thinlto' -S %s 2>&1 \
4747 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-POSTLINK-O,CHECK-POSTLINK-O2
4848 ;
49 ; CHECK-O: Running analysis: PassInstrumentationAnalysis
50 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
49 ; CHECK-O: Starting llvm::Module pass manager run.
5150 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
5251 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
5352 ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
6463 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
6564 ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
6665 ; CHECK-PRELINK-O-NODIS-NEXT: Running analysis: InnerAnalysisManagerProxy
67 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
6866 ; CHECK-O-NEXT: Starting llvm::Function pass manager run.
6967 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass
7068 ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis
9694 ; CHECK-O-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor<{{.*}}LazyCallGraph{{.*}}>
9795 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
9896 ; CHECK-O-NEXT: Running analysis: LazyCallGraphAnalysis
99 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
10097 ; CHECK-O-NEXT: Starting CGSCC pass manager run.
10198 ; CHECK-O-NEXT: Running pass: InlinerPass
10299 ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph{{.*}}>
135132 ; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis
136133 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
137134 ; CHECK-O-NEXT: Starting Loop pass manager run.
138 ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis
139135 ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass
140136 ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass
141137 ; CHECK-O-NEXT: Running pass: LoopRotatePass
3232 ; CHECK-NEXT: Running pass: DominatorTreeVerifierPass on test1_g
3333 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on test1_g
3434 ; CHECK-NEXT: Finished llvm::Function pass manager run.
35 ; CHECK-NOT: Invalidating analysis:
36 ; CHECK: Starting llvm::Function pass manager run.
35 ; CHECK-NEXT: Starting llvm::Function pass manager run.
3736 ; CHECK-NEXT: Running pass: DominatorTreeVerifierPass on test1_h
3837 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on test1_h
3938 ; CHECK-NEXT: Finished llvm::Function pass manager run.
2020 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
2121 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
2222 ; CHECK-NEXT: Starting Loop pass manager run.
23 ; CHECK-NEXT: Running analysis: PassInstrumentationAnalysis on bb
2423 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb
,%bb4
2524 ; CHECK-NEXT: Folding loop latch bb4 into bb
2625 ; CHECK-NEXT: Invalidating all non-preserved analyses for: bb
230230 MAM.registerPass([&] { return TargetLibraryAnalysis(); });
231231 MAM.registerPass([&] { return LazyCallGraphAnalysis(); });
232232 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
233
234 // Register required pass instrumentation analysis.
235 MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
236 CGAM.registerPass([&] { return PassInstrumentationAnalysis(); });
237 FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
238
239 // Cross-register proxies.
240233 MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); });
241234 CGAM.registerPass([&] { return FunctionAnalysisManagerCGSCCProxy(); });
242235 CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); });
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include
109 #include
1110 #include
12 #include
1311 #include
1412 #include
1513 #include
1614 #include
17 #include
1815 #include
1916 #include
20 #include
2117 #include
2218 #include
2319
3531 }
3632
3733 namespace {
38 using testing::AnyNumber;
39 using testing::AtLeast;
4034 using testing::DoDefault;
41 using testing::Not;
4235 using testing::Return;
4336 using testing::Expectation;
4437 using testing::Invoke;
9386 typename Analysis::Result getResult() {
9487 return typename Analysis::Result(static_cast(*this));
9588 }
96 static StringRef getName() { return llvm::getTypeName(); }
9789
9890 protected:
9991 // FIXME: MSVC seems unable to handle a lambda argument to Invoke from within
150142 }
151143 };
152144
153 static StringRef getName() { return llvm::getTypeName(); }
154
155145 Pass getPass() { return Pass(static_cast(*this)); }
156146
157147 protected:
266256 SMDiagnostic Err;
267257 return parseAssemblyString(IR, Err, C);
268258 }
269
270 /// Helper for HasName matcher that returns getName both for IRUnit and
271 /// for IRUnit pointer wrapper into llvm::Any (wrapped by PassInstrumentation).
272 template StringRef getName(const IRUnitT &IR) {
273 return IR.getName();
274 }
275
276 template <> StringRef getName(const StringRef &name) { return name; }
277
278 template <> StringRef getName(const llvm::Any &WrappedIR) {
279 if (any_isa(WrappedIR))
280 return any_cast(WrappedIR)->getName();
281 if (any_isa(WrappedIR))
282 return any_cast(WrappedIR)->getName();
283 if (any_isa(WrappedIR))
284 return any_cast(WrappedIR)->getName();
285 if (any_isa(WrappedIR))
286 return any_cast(WrappedIR)->getName();
287 return "";
288 }
289 /// Define a custom matcher for objects which support a 'getName' method.
290 ///
291 /// LLVM often has IR objects or analysis objects which expose a name
292 /// and in tests it is convenient to match these by name for readability.
293 /// Usually, this name is either a StringRef or a plain std::string. This
294 /// matcher supports any type exposing a getName() method of this form whose
295 /// return value is compatible with an std::ostream. For StringRef, this uses
296 /// the shift operator defined above.
297 ///
298 /// It should be used as:
299 ///
300 /// HasName("my_function")
301 ///
302 /// No namespace or other qualification is required.
303 MATCHER_P(HasName, Name, "") {
304 *result_listener << "has name '" << getName(arg) << "'";
305 return Name == getName(arg);
306 }
307
308 MATCHER_P(HasNameRegex, Name, "") {
309 *result_listener << "has name '" << getName(arg) << "'";
310 llvm::Regex r(Name);
311 return r.match(getName(arg));
312 }
313
314 struct MockPassInstrumentationCallbacks {
315 PassInstrumentationCallbacks Callbacks;
316
317 MockPassInstrumentationCallbacks() {
318 ON_CALL(*this, runBeforePass(_, _)).WillByDefault(Return(true));
319 }
320 MOCK_METHOD2(runBeforePass, bool(StringRef PassID, llvm::Any));
321 MOCK_METHOD2(runAfterPass, void(StringRef PassID, llvm::Any));
322
323 void registerPassInstrumentation() {
324 Callbacks.registerBeforePassCallback([this](StringRef P, llvm::Any IR) {
325 return this->runBeforePass(P, IR);
326 });
327 Callbacks.registerAfterPassCallback(
328 [this](StringRef P, llvm::Any IR) { this->runAfterPass(P, IR); });
329 }
330
331 void ignoreNonMockPassInstrumentation(StringRef IRName) {
332 // Generic EXPECT_CALLs are needed to match instrumentation on unimportant
333 // parts of a pipeline that we do not care about (e.g. various passes added
334 // by default by PassBuilder - Verifier pass etc).
335 // Make sure to avoid ignoring Mock passes/analysis, we definitely want
336 // to check these explicitly.
337 EXPECT_CALL(*this,
338 runBeforePass(Not(HasNameRegex("Mock")), HasName(IRName)))
339 .Times(AnyNumber());
340 EXPECT_CALL(*this, runAfterPass(Not(HasNameRegex("Mock")), HasName(IRName)))
341 .Times(AnyNumber());
342 }
343 };
344259
345260 template class PassBuilderCallbacksTest;
346261
363278
364279 LLVMContext Context;
365280 std::unique_ptr M;
366
367 MockPassInstrumentationCallbacks CallbacksHandle;
368281
369282 PassBuilder PB;
370283 ModulePassManager PM;
398311 "exit:\n"
399312 " ret void\n"
400313 "}\n")),
401 CallbacksHandle(), PB(nullptr, None, &CallbacksHandle.Callbacks),
402314 PM(true), LAM(true), FAM(true), CGAM(true), AM(true) {
403315
404316 /// Register a callback for analysis registration.
443355 }
444356 };
445357
358 /// Define a custom matcher for objects which support a 'getName' method.
359 ///
360 /// LLVM often has IR objects or analysis objects which expose a name
361 /// and in tests it is convenient to match these by name for readability.
362 /// Usually, this name is either a StringRef or a plain std::string. This
363 /// matcher supports any type exposing a getName() method of this form whose
364 /// return value is compatible with an std::ostream. For StringRef, this uses
365 /// the shift operator defined above.
366 ///
367 /// It should be used as:
368 ///
369 /// HasName("my_function")
370 ///
371 /// No namespace or other qualification is required.
372 MATCHER_P(HasName, Name, "") {
373 *result_listener << "has name '" << arg.getName() << "'";
374 return Name == arg.getName();
375 }
376
446377 using ModuleCallbacksTest = PassBuilderCallbacksTest;
447378 using CGSCCCallbacksTest = PassBuilderCallbacksTest;
448379 using FunctionCallbacksTest = PassBuilderCallbacksTest;
459390 StringRef PipelineText = "test-transform";
460391 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
461392 << "Pipeline was: " << PipelineText;
462
463 PM.run(*M, AM);
464 }
465
466 TEST_F(ModuleCallbacksTest, InstrumentedPasses) {
467 EXPECT_CALL(AnalysisHandle, run(HasName(""), _));
468 EXPECT_CALL(PassHandle, run(HasName(""), _))
469 .WillOnce(Invoke(getAnalysisResult));
470
471 CallbacksHandle.registerPassInstrumentation();
472 // Non-mock instrumentation not specifically mentioned below can be ignored.
473 CallbacksHandle.ignoreNonMockPassInstrumentation("");
474
475 // PassInstrumentation calls should happen in-sequence, in the same order
476 // as passes/analyses are scheduled.
477 ::testing::Sequence PISequence;
478 EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"),
479 HasName("")))
480 .InSequence(PISequence);
481 EXPECT_CALL(CallbacksHandle,
482 runAfterPass(HasNameRegex("MockPassHandle"), HasName("")))
483 .InSequence(PISequence);
484
485 StringRef PipelineText = "test-transform";
486 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
487 << "Pipeline was: " << PipelineText;
488
489 PM.run(*M, AM);
490 }
491
492 TEST_F(ModuleCallbacksTest, InstrumentedSkippedPasses) {
493 CallbacksHandle.registerPassInstrumentation();
494 // Non-mock instrumentation run here can safely be ignored.
495 CallbacksHandle.ignoreNonMockPassInstrumentation("");
496
497 // Skip the pass by returning false.
498 EXPECT_CALL(CallbacksHandle, runBeforePass(HasNameRegex("MockPassHandle"),
499 HasName("")))
500 .WillOnce(Return(false));
501
502 EXPECT_CALL(AnalysisHandle, run(HasName(""), _)).Times(0);
503 EXPECT_CALL(PassHandle, run(HasName(""), _)).Times(0);
504
505 // As the pass is skipped there is no afterPass as well.
506 EXPECT_CALL(CallbacksHandle, runAfterPass(HasNameRegex("MockPassHandle"), _))
507 .Times(0);
508
509 StringRef PipelineText = "test-transform";
510 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
511 << "Pipeline was: " << PipelineText;
512
513393 PM.run(*M, AM);
514394 }
515395
524404 PM.run(*M, AM);
525405 }
526406
527 TEST_F(FunctionCallbacksTest, InstrumentedPasses) {
528 CallbacksHandle.registerPassInstrumentation();
529 // Non-mock instrumentation not specifically mentioned below can be ignored.
530 CallbacksHandle.ignoreNonMockPassInstrumentation("");
531 CallbacksHandle.ignoreNonMockPassInstrumentation("foo");
532
533 EXPECT_CALL(AnalysisHandle, run(HasName("foo"), _));
534 EXPECT_CALL(PassHandle, run(HasName("foo"), _))
535 .WillOnce(Invoke(getAnalysisResult));
536
537 // PassInstrumentation calls should happen in-sequence, in the same order
538 // as passes/analyses are scheduled.
539 ::testing::Sequence PISequence;
540 EXPECT_CALL(CallbacksHandle,
541 runBeforePass(HasNameRegex("MockPassHandle"), HasName("foo")))
542 .InSequence(PISequence);
543 EXPECT_CALL(CallbacksHandle,
544 runAfterPass(HasNameRegex("MockPassHandle"), HasName("foo")))
545 .InSequence(PISequence);
546
547 StringRef PipelineText = "test-transform";
548 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
549 << "Pipeline was: " << PipelineText;
550 PM.run(*M, AM);
551 }
552
553 TEST_F(FunctionCallbacksTest, InstrumentedSkippedPasses) {
554 CallbacksHandle.registerPassInstrumentation();
555 // Non-mock instrumentation run here can safely be ignored.
556 CallbacksHandle.ignoreNonMockPassInstrumentation("");
557 CallbacksHandle.ignoreNonMockPassInstrumentation("foo");
558
559 // Skip the pass by returning false.
560 EXPECT_CALL(CallbacksHandle,
561 runBeforePass(HasNameRegex("MockPassHandle"), HasName("foo")))
562 .WillOnce(Return(false));
563
564 EXPECT_CALL(AnalysisHandle, run(HasName("foo"), _)).Times(0);
565 EXPECT_CALL(PassHandle, run(HasName("foo"), _)).Times(0);
566
567 // As the pass is skipped there is no afterPass as well.
568 EXPECT_CALL(CallbacksHandle, runAfterPass(HasNameRegex("MockPassHandle"), _))
569 .Times(0);
570
571 StringRef PipelineText = "test-transform";
572 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
573 << "Pipeline was: " << PipelineText;
574 PM.run(*M, AM);
575 }
576
577407 TEST_F(LoopCallbacksTest, Passes) {
578408 EXPECT_CALL(AnalysisHandle, run(HasName("loop"), _, _));
579409 EXPECT_CALL(PassHandle, run(HasName("loop"), _, _, _))
585415 PM.run(*M, AM);
586416 }
587417
588 TEST_F(LoopCallbacksTest, InstrumentedPasses) {
589 CallbacksHandle.registerPassInstrumentation();
590 // Non-mock instrumentation not specifically mentioned below can be ignored.
591 CallbacksHandle.ignoreNonMockPassInstrumentation("");
592 CallbacksHandle.ignoreNonMockPassInstrumentation("foo");
593 CallbacksHandle.ignoreNonMockPassInstrumentation("loop");
594
595 EXPECT_CALL(AnalysisHandle, run(HasName("loop"), _, _));
596 EXPECT_CALL(PassHandle, run(HasName("loop"), _, _, _))
597 .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult)));
598
599 // PassInstrumentation calls should happen in-sequence, in the same order
600 // as passes/analyses are scheduled.
601 ::testing::Sequence PISequence;
602 EXPECT_CALL(CallbacksHandle,
603 runBeforePass(HasNameRegex("MockPassHandle"), HasName("loop")))
604 .InSequence(PISequence);
605 EXPECT_CALL(CallbacksHandle,
606 runAfterPass(HasNameRegex("MockPassHandle"), HasName("loop")))
607 .InSequence(PISequence);
608
609 StringRef PipelineText = "test-transform";
610 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
611 << "Pipeline was: " << PipelineText;
612 PM.run(*M, AM);
613 }
614
615 TEST_F(LoopCallbacksTest, InstrumentedSkippedPasses) {
616 CallbacksHandle.registerPassInstrumentation();
617 // Non-mock instrumentation run here can safely be ignored.
618 CallbacksHandle.ignoreNonMockPassInstrumentation("");
619 CallbacksHandle.ignoreNonMockPassInstrumentation("foo");
620 CallbacksHandle.ignoreNonMockPassInstrumentation("loop");
621
622 // Skip the pass by returning false.
623 EXPECT_CALL(CallbacksHandle,
624 runBeforePass(HasNameRegex("MockPassHandle"), HasName("loop")))
625 .WillOnce(Return(false));
626
627 EXPECT_CALL(AnalysisHandle, run(HasName("loop"), _, _)).Times(0);
628 EXPECT_CALL(PassHandle, run(HasName("loop"), _, _, _)).Times(0);
629
630 // As the pass is skipped there is no afterPass as well.
631 EXPECT_CALL(CallbacksHandle, runAfterPass(HasNameRegex("MockPassHandle"), _))
632 .Times(0);
633
634 StringRef PipelineText = "test-transform";
635 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
636 << "Pipeline was: " << PipelineText;
637 PM.run(*M, AM);
638 }
639
640418 TEST_F(CGSCCCallbacksTest, Passes) {
641419 EXPECT_CALL(AnalysisHandle, run(HasName("(foo)"), _, _));
642420 EXPECT_CALL(PassHandle, run(HasName("(foo)"), _, _, _))
643421 .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult)));
644
645 StringRef PipelineText = "test-transform";
646 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
647 << "Pipeline was: " << PipelineText;
648 PM.run(*M, AM);
649 }
650
651 TEST_F(CGSCCCallbacksTest, InstrumentedPasses) {
652 CallbacksHandle.registerPassInstrumentation();
653 // Non-mock instrumentation not specifically mentioned below can be ignored.
654 CallbacksHandle.ignoreNonMockPassInstrumentation("");
655 CallbacksHandle.ignoreNonMockPassInstrumentation("(foo)");
656
657 EXPECT_CALL(AnalysisHandle, run(HasName("(foo)"), _, _));
658 EXPECT_CALL(PassHandle, run(HasName("(foo)"), _, _, _))
659 .WillOnce(WithArgs<0, 1, 2>(Invoke(getAnalysisResult)));
660
661 // PassInstrumentation calls should happen in-sequence, in the same order
662 // as passes/analyses are scheduled.
663 ::testing::Sequence PISequence;
664 EXPECT_CALL(CallbacksHandle,
665 runBeforePass(HasNameRegex("MockPassHandle"), HasName("(foo)")))
666 .InSequence(PISequence);
667 EXPECT_CALL(CallbacksHandle,
668 runAfterPass(HasNameRegex("MockPassHandle"), HasName("(foo)")))
669 .InSequence(PISequence);
670
671 StringRef PipelineText = "test-transform";
672 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
673 << "Pipeline was: " << PipelineText;
674 PM.run(*M, AM);
675 }
676
677 TEST_F(CGSCCCallbacksTest, InstrumentedSkippedPasses) {
678 CallbacksHandle.registerPassInstrumentation();
679 // Non-mock instrumentation run here can safely be ignored.
680 CallbacksHandle.ignoreNonMockPassInstrumentation("");
681 CallbacksHandle.ignoreNonMockPassInstrumentation("(foo)");
682
683 // Skip the pass by returning false.
684 EXPECT_CALL(CallbacksHandle,
685 runBeforePass(HasNameRegex("MockPassHandle"), HasName("(foo)")))
686 .WillOnce(Return(false));
687
688 // neither Analysis nor Pass are called.
689 EXPECT_CALL(AnalysisHandle, run(HasName("(foo)"), _, _)).Times(0);
690 EXPECT_CALL(PassHandle, run(HasName("(foo)"), _, _, _)).Times(0);
691
692 // As the pass is skipped there is no afterPass as well.
693 EXPECT_CALL(CallbacksHandle, runAfterPass(HasNameRegex("MockPassHandle"), _))
694 .Times(0);
695422
696423 StringRef PipelineText = "test-transform";
697424 ASSERT_TRUE(PB.parsePassPipeline(PM, PipelineText, true))
404404 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); });
405405 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
406406 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
407
408 MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
409 FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
410407
411408 ModulePassManager MPM;
412409
558555 TEST_F(PassManagerTest, CustomizedPassManagerArgs) {
559556 CustomizedAnalysisManager AM;
560557 AM.registerPass([&] { return CustomizedAnalysis(); });
561 PassInstrumentationCallbacks PIC;
562 AM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
563558
564559 CustomizedPassManager PM;
565560
691686 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); });
692687 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
693688 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
694
695 PassInstrumentationCallbacks PIC;
696 MAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
697 FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
698689
699690 int InstrCount = 0, FunctionCount = 0;
700691 ModulePassManager MPM(/*DebugLogging*/ true);
306306 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
307307 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
308308 FAM.registerPass([&] { return TargetIRAnalysis(); });
309
310 // Register required pass instrumentation analysis.
311 LAM.registerPass([&] { return PassInstrumentationAnalysis(); });
312 FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
313 MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
314309
315310 // Cross-register proxies.
316311 LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); });