llvm.org GIT mirror llvm / f5f73cd
Revert "Introduce RegionInfoAnalysis, which compute Region Tree in the new PassManager. NFC" This reverts commit 8228b4d374edeb4cc0c5fddf6e1ab876918ee126. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261889 91177308-0d34-0410-b5e6-96231b3b80d8 Hongbin Zheng 4 years ago
22 changed file(s) with 0 addition(s) and 149 deletion(s). Raw diff Collapse all Expand all
4646
4747 namespace llvm {
4848
49 // FIXME: Replace this brittle forward declaration with the include of the new
50 // PassManager.h when doing so doesn't break the PassManagerBuilder.
51 template class AnalysisManager;
52 class PreservedAnalyses;
53
5449 // Class to be specialized for different users of RegionInfo
5550 // (i.e. BasicBlocks or MachineBasicBlocks). This is only to avoid needing to
5651 // pass around an unreasonable number of template parameters.
680675 RegionInfoBase(const RegionInfoBase &) = delete;
681676 const RegionInfoBase &operator=(const RegionInfoBase &) = delete;
682677
683 RegionInfoBase(RegionInfoBase &&Arg)
684 : DT(std::move(Arg.DT)), PDT(std::move(Arg.PDT)), DF(std::move(Arg.DF)),
685 TopLevelRegion(std::move(Arg.TopLevelRegion)),
686 BBtoRegion(std::move(Arg.BBtoRegion)) {
687 Arg.wipe();
688 }
689 RegionInfoBase &operator=(RegionInfoBase &&RHS) {
690 DT = std::move(RHS.DT);
691 PDT = std::move(RHS.PDT);
692 DF = std::move(RHS.DF);
693 TopLevelRegion = std::move(RHS.TopLevelRegion);
694 BBtoRegion = std::move(RHS.BBtoRegion);
695 RHS.wipe();
696 return *this;
697 }
698
699678 DomTreeT *DT;
700679 PostDomTreeT *PDT;
701680 DomFrontierT *DF;
706685 private:
707686 /// Map every BB to the smallest region, that contains BB.
708687 BBtoRegionMap BBtoRegion;
709
710 /// \brief Wipe this region tree's state without releasing any resources.
711 ///
712 /// This is essentially a post-move helper only. It leaves the object in an
713 /// assignable and destroyable state, but otherwise invalid.
714 void wipe() {
715 DT = nullptr;
716 PDT = nullptr;
717 DF = nullptr;
718 TopLevelRegion = nullptr;
719 BBtoRegion.clear();
720 }
721688
722689 // Check whether the entries of BBtoRegion for the BBs of region
723690 // SR are correct. Triggers an assertion if not. Calls itself recursively for
868835
869836 class RegionInfo : public RegionInfoBase> {
870837 public:
871 typedef RegionInfoBase> Base;
872
873838 explicit RegionInfo();
874839
875840 ~RegionInfo() override;
876
877 RegionInfo(RegionInfo &&Arg)
878 : Base(std::move(static_cast(Arg))) {}
879 RegionInfo &operator=(RegionInfo &&RHS) {
880 Base::operator=(std::move(static_cast(RHS)));
881 return *this;
882 }
883841
884842 // updateStatistics - Update statistic about created regions.
885843 void updateStatistics(Region *R) final;
925883 //@}
926884 };
927885
928 /// \brief Analysis pass that exposes the \c RegionInfo for a function.
929 class RegionInfoAnalysis {
930 static char PassID;
931
932 public:
933 typedef RegionInfo Result;
934
935 /// \brief Opaque, unique identifier for this analysis pass.
936 static void *ID() { return (void *)&PassID; }
937
938 /// \brief Provide a name for the analysis for debugging and logging.
939 static StringRef name() { return "RegionInfoAnalysis"; }
940
941 RegionInfo run(Function &F, AnalysisManager *AM);
942 };
943
944 /// \brief Printer pass for the \c RegionInfo.
945 class RegionInfoPrinterPass {
946 raw_ostream &OS;
947
948 public:
949 explicit RegionInfoPrinterPass(raw_ostream &OS);
950 PreservedAnalyses run(Function &F, AnalysisManager *AM);
951
952 static StringRef name() { return "RegionInfoPrinterPass"; }
953 };
954
955 /// \brief Verifier pass for the \c RegionInfo.
956 struct RegionInfoVerifierPass {
957 PreservedAnalyses run(Function &F, AnalysisManager *AM);
958
959 static StringRef name() { return "RegionInfoVerifierPass"; }
960 };
961
962886 template <>
963887 template <>
964888 inline BasicBlock *
1414 #include "llvm/Analysis/LoopInfo.h"
1515 #include "llvm/Analysis/RegionInfoImpl.h"
1616 #include "llvm/Analysis/RegionIterator.h"
17 #include "llvm/IR/PassManager.h"
1817 #include "llvm/Support/CommandLine.h"
1918 #include "llvm/Support/Debug.h"
2019 #include "llvm/Support/ErrorHandling.h"
180179 }
181180 }
182181
183 //===----------------------------------------------------------------------===//
184 // RegionInfoAnalysis implementation
185 //
186
187 char RegionInfoAnalysis::PassID;
188
189 RegionInfo RegionInfoAnalysis::run(Function &F, AnalysisManager *AM) {
190 RegionInfo RI;
191 auto *DT = &AM->getResult(F);
192 auto *PDT = &AM->getResult(F);
193 auto *DF = &AM->getResult(F);
194
195 RI.recalculate(F, DT, PDT, DF);
196 return RI;
197 }
198
199 RegionInfoPrinterPass::RegionInfoPrinterPass(raw_ostream &OS)
200 : OS(OS) {}
201
202 PreservedAnalyses
203 RegionInfoPrinterPass::run(Function &F, FunctionAnalysisManager *AM) {
204 OS << "Region Tree for function: " << F.getName() << "\n";
205 AM->getResult(F).print(OS);
206
207 return PreservedAnalyses::all();
208 }
209
210 PreservedAnalyses RegionInfoVerifierPass::run(Function &F,
211 AnalysisManager *AM) {
212 AM->getResult(F).verifyAnalysis();
213
214 return PreservedAnalyses::all();
215 }
2525 #include "llvm/Analysis/LazyCallGraph.h"
2626 #include "llvm/Analysis/LoopInfo.h"
2727 #include "llvm/Analysis/PostDominators.h"
28 #include "llvm/Analysis/RegionInfo.h"
2928 #include "llvm/Analysis/ScalarEvolution.h"
3029 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
3130 #include "llvm/Analysis/ScopedNoAliasAA.h"
5959 FUNCTION_ANALYSIS("postdomtree", PostDominatorTreeAnalysis())
6060 FUNCTION_ANALYSIS("domfrontier", DominanceFrontierAnalysis())
6161 FUNCTION_ANALYSIS("loops", LoopAnalysis())
62 FUNCTION_ANALYSIS("regions", RegionInfoAnalysis())
6362 FUNCTION_ANALYSIS("no-op-function", NoOpFunctionAnalysis())
6463 FUNCTION_ANALYSIS("scalar-evolution", ScalarEvolutionAnalysis())
6564 FUNCTION_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
9493 FUNCTION_PASS("print", PostDominatorTreePrinterPass(dbgs()))
9594 FUNCTION_PASS("print", DominanceFrontierPrinterPass(dbgs()))
9695 FUNCTION_PASS("print", LoopPrinterPass(dbgs()))
97 FUNCTION_PASS("print", RegionInfoPrinterPass(dbgs()))
9896 FUNCTION_PASS("print", ScalarEvolutionPrinterPass(dbgs()))
9997 FUNCTION_PASS("simplify-cfg", SimplifyCFGPass())
10098 FUNCTION_PASS("sroa", SROA())
10199 FUNCTION_PASS("verify", VerifierPass())
102100 FUNCTION_PASS("verify", DominatorTreeVerifierPass())
103 FUNCTION_PASS("verify", RegionInfoVerifierPass())
104101 #undef FUNCTION_PASS
105102
106103 #ifndef LOOP_ANALYSIS
0 ; RUN: opt -regions < %s
1 ; RUN: opt < %s -passes='print'
2
31 define i32 @main() nounwind {
42 entry:
53 br label %for.cond
22 ; RUN: opt -regions -stats -analyze < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @BZ2_blockSort() nounwind {
97 start:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @normal_condition() nounwind {
97 5:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define internal fastcc zeroext i8 @handle_compress() nounwind {
97 end165:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define internal fastcc void @compress() nounwind {
97 end33:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @normal_condition() nounwind {
97 0:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @normal_condition() nounwind {
97 0:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @normal_condition() nounwind {
97 0:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define internal fastcc zeroext i8 @handle_compress() nounwind {
97 entry:
33
44 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
55 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
6
7 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
86
97 define void @normal_condition() nounwind {
108 0:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define internal fastcc zeroext i8 @loops_1() nounwind {
97 entry:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @meread_() nounwind {
97 entry:
33
44 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
55 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
6
7 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
86
97 define void @a_linear_impl_fig_1() nounwind {
108 0:
33
44 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
55 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
6
7 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
86
97 define internal fastcc zeroext i8 @handle_compress() nounwind {
108 entry:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @MAIN__() nounwind {
97 entry:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define void @a_linear_impl_fig_1() nounwind {
97 0:
22 ; RUN: opt -regions -stats < %s 2>&1 | FileCheck -check-prefix=STAT %s
33 ; RUN: opt -regions -print-region-style=bb -analyze < %s 2>&1 | FileCheck -check-prefix=BBIT %s
44 ; RUN: opt -regions -print-region-style=rn -analyze < %s 2>&1 | FileCheck -check-prefix=RNIT %s
5
6 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
75
86 define internal fastcc zeroext i8 @handle_compress() nounwind {
97 entry:
0 ; RUN: opt -regions -analyze < %s | FileCheck %s
1 ; RUN: opt < %s -passes='print' 2>&1 | FileCheck %s
21
32 ; We should not crash if there are some bbs that are not reachable.
43 define void @f() {