llvm.org GIT mirror llvm / eb06640
[PM/IPO] Port LowerTypeTests to the new PassManager. There's a little bit of churn in this patch because the initialization mechanism is now shared between the old and the new PM. Other than that, it's just a pretty mechanical translation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275082 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
5 changed file(s) with 39 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
1616
1717 #include "llvm/ADT/DenseMap.h"
1818 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/IR/PassManager.h"
1921
2022 #include
2123 #include
199201 };
200202
201203 } // end namespace lowertypetests
204
205 class LowerTypeTestsPass : public PassInfoMixin {
206 public:
207 PreservedAnalyses run(Module &M, AnalysisManager &AM);
208 };
209
202210 } // end namespace llvm
203211
204212 #endif // LLVM_TRANSFORMS_IPO_LOWERTYPETESTS_H
6565 #include "llvm/Transforms/IPO/GlobalOpt.h"
6666 #include "llvm/Transforms/IPO/InferFunctionAttrs.h"
6767 #include "llvm/Transforms/IPO/Internalize.h"
68 #include "llvm/Transforms/IPO/LowerTypeTests.h"
6869 #include "llvm/Transforms/IPO/PartialInlining.h"
6970 #include "llvm/Transforms/IPO/SCCP.h"
7071 #include "llvm/Transforms/IPO/StripDeadPrototypes.h"
4949 MODULE_PASS("internalize", InternalizePass())
5050 MODULE_PASS("invalidate", InvalidateAllAnalysesPass())
5151 MODULE_PASS("ipsccp", IPSCCPPass())
52 MODULE_PASS("lowertypetests", LowerTypeTestsPass())
5253 MODULE_PASS("no-op-module", NoOpModulePass())
5354 MODULE_PASS("partial-inliner", PartialInlinerPass())
5455 MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
984984 return true;
985985 }
986986
987 // Initialization helper shared by the old and the new PM.
988 static void init(LowerTypeTests *LTT, Module &M) {
989 LTT->M = &M;
990 const DataLayout &DL = M.getDataLayout();
991 Triple TargetTriple(M.getTargetTriple());
992 LTT->LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX();
993 LTT->Arch = TargetTriple.getArch();
994 LTT->ObjectFormat = TargetTriple.getObjectFormat();
995 LTT->Int1Ty = Type::getInt1Ty(M.getContext());
996 LTT->Int8Ty = Type::getInt8Ty(M.getContext());
997 LTT->Int32Ty = Type::getInt32Ty(M.getContext());
998 LTT->Int32PtrTy = PointerType::getUnqual(LTT->Int32Ty);
999 LTT->Int64Ty = Type::getInt64Ty(M.getContext());
1000 LTT->IntPtrTy = DL.getIntPtrType(M.getContext(), 0);
1001 LTT->TypeTestCallSites.clear();
1002 }
1003
9871004 bool LowerTypeTests::runOnModule(Module &M) {
9881005 if (skipModule(M))
9891006 return false;
990
991 this->M = &M;
992 const DataLayout &DL = M.getDataLayout();
993
994 Triple TargetTriple(M.getTargetTriple());
995 LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX();
996 Arch = TargetTriple.getArch();
997 ObjectFormat = TargetTriple.getObjectFormat();
998
999 Int1Ty = Type::getInt1Ty(M.getContext());
1000 Int8Ty = Type::getInt8Ty(M.getContext());
1001 Int32Ty = Type::getInt32Ty(M.getContext());
1002 Int32PtrTy = PointerType::getUnqual(Int32Ty);
1003 Int64Ty = Type::getInt64Ty(M.getContext());
1004 IntPtrTy = DL.getIntPtrType(M.getContext(), 0);
1005
1006 TypeTestCallSites.clear();
1007 init(this, M);
10071008 return lower();
10081009 }
1010
1011 PreservedAnalyses LowerTypeTestsPass::run(Module &M,
1012 AnalysisManager &AM) {
1013 LowerTypeTests Impl;
1014 init(&Impl, M);
1015 bool Changed = Impl.lower();
1016 if (!Changed)
1017 return PreservedAnalyses::all();
1018 return PreservedAnalyses::none();
1019 }
0 ; RUN: opt -S -lowertypetests < %s | FileCheck %s
1 ; RUN: opt -S -passes=lowertypetests < %s | FileCheck %s
12
23 target datalayout = "e-p:32:32"
34