Mercurial > hg > CbC > CbC_llvm
comparison unittests/IR/PassManagerTest.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
comparison
equal
deleted
inserted
replaced
146:3fc4d5c3e21e | 148:63bd29f05246 |
---|---|
1 //===- llvm/unittest/IR/PassManager.cpp - PassManager tests ---------------===// | 1 //===- llvm/unittest/IR/PassManager.cpp - PassManager tests ---------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 | 8 |
10 #include "llvm/IR/PassManager.h" | 9 #include "llvm/IR/PassManager.h" |
11 #include "llvm/AsmParser/Parser.h" | 10 #include "llvm/AsmParser/Parser.h" |
26 int InstructionCount; | 25 int InstructionCount; |
27 }; | 26 }; |
28 | 27 |
29 TestFunctionAnalysis(int &Runs) : Runs(Runs) {} | 28 TestFunctionAnalysis(int &Runs) : Runs(Runs) {} |
30 | 29 |
31 /// \brief Run the analysis pass over the function and return a result. | 30 /// Run the analysis pass over the function and return a result. |
32 Result run(Function &F, FunctionAnalysisManager &AM) { | 31 Result run(Function &F, FunctionAnalysisManager &AM) { |
33 ++Runs; | 32 ++Runs; |
34 int Count = 0; | 33 int Count = 0; |
35 for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) | 34 for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) |
36 for (BasicBlock::iterator II = BBI->begin(), IE = BBI->end(); II != IE; | 35 for (BasicBlock::iterator II = BBI->begin(), IE = BBI->end(); II != IE; |
403 ModuleAnalysisManager MAM(/*DebugLogging*/ true); | 402 ModuleAnalysisManager MAM(/*DebugLogging*/ true); |
404 int ModuleAnalysisRuns = 0; | 403 int ModuleAnalysisRuns = 0; |
405 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); | 404 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); |
406 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); | 405 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); |
407 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); | 406 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); |
407 | |
408 MAM.registerPass([&] { return PassInstrumentationAnalysis(); }); | |
409 FAM.registerPass([&] { return PassInstrumentationAnalysis(); }); | |
408 | 410 |
409 ModulePassManager MPM; | 411 ModulePassManager MPM; |
410 | 412 |
411 // Count the runs over a Function. | 413 // Count the runs over a Function. |
412 int FunctionPassRunCount1 = 0; | 414 int FunctionPassRunCount1 = 0; |
554 }; | 556 }; |
555 | 557 |
556 TEST_F(PassManagerTest, CustomizedPassManagerArgs) { | 558 TEST_F(PassManagerTest, CustomizedPassManagerArgs) { |
557 CustomizedAnalysisManager AM; | 559 CustomizedAnalysisManager AM; |
558 AM.registerPass([&] { return CustomizedAnalysis(); }); | 560 AM.registerPass([&] { return CustomizedAnalysis(); }); |
561 PassInstrumentationCallbacks PIC; | |
562 AM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); }); | |
559 | 563 |
560 CustomizedPassManager PM; | 564 CustomizedPassManager PM; |
561 | 565 |
562 // Add an instance of the customized pass that just accumulates the input | 566 // Add an instance of the customized pass that just accumulates the input |
563 // after it is round-tripped through the analysis. | 567 // after it is round-tripped through the analysis. |
685 | 689 |
686 ModuleAnalysisManager MAM(/*DebugLogging*/ true); | 690 ModuleAnalysisManager MAM(/*DebugLogging*/ true); |
687 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); | 691 MAM.registerPass([&] { return TestModuleAnalysis(ModuleAnalysisRuns); }); |
688 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); | 692 MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); }); |
689 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); | 693 FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); }); |
694 | |
695 PassInstrumentationCallbacks PIC; | |
696 MAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); }); | |
697 FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); }); | |
690 | 698 |
691 int InstrCount = 0, FunctionCount = 0; | 699 int InstrCount = 0, FunctionCount = 0; |
692 ModulePassManager MPM(/*DebugLogging*/ true); | 700 ModulePassManager MPM(/*DebugLogging*/ true); |
693 FunctionPassManager FPM(/*DebugLogging*/ true); | 701 FunctionPassManager FPM(/*DebugLogging*/ true); |
694 // First just use the analysis to get the instruction count, and preserve | 702 // First just use the analysis to get the instruction count, and preserve |