summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-07-11 18:10:06 +0000
committerDavide Italiano <davide@freebsd.org>2016-07-11 18:10:06 +0000
commiteb0664013d9684902f776fbde4061666fc64080d (patch)
treec40c12038446b41193d42ab8b9648e354c2c346b
parent9ba010ec8454e20102a92cdeb3e0babe83c833b0 (diff)
[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
-rw-r--r--include/llvm/Transforms/IPO/LowerTypeTests.h8
-rw-r--r--lib/Passes/PassBuilder.cpp1
-rw-r--r--lib/Passes/PassRegistry.def1
-rw-r--r--lib/Transforms/IPO/LowerTypeTests.cpp45
-rw-r--r--test/Transforms/LowerTypeTests/constant.ll1
5 files changed, 39 insertions, 17 deletions
diff --git a/include/llvm/Transforms/IPO/LowerTypeTests.h b/include/llvm/Transforms/IPO/LowerTypeTests.h
index 4da2a06aa94..93d4fb94e2c 100644
--- a/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -17,6 +17,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
#include <cstdint>
#include <cstring>
@@ -200,6 +202,12 @@ struct ByteArrayBuilder {
};
} // end namespace lowertypetests
+
+class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
+public:
+ PreservedAnalyses run(Module &M, AnalysisManager<Module> &AM);
+};
+
} // end namespace llvm
#endif // LLVM_TRANSFORMS_IPO_LOWERTYPETESTS_H
diff --git a/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp
index 8292214c17f..18e271c75b8 100644
--- a/lib/Passes/PassBuilder.cpp
+++ b/lib/Passes/PassBuilder.cpp
@@ -66,6 +66,7 @@
#include "llvm/Transforms/IPO/GlobalOpt.h"
#include "llvm/Transforms/IPO/InferFunctionAttrs.h"
#include "llvm/Transforms/IPO/Internalize.h"
+#include "llvm/Transforms/IPO/LowerTypeTests.h"
#include "llvm/Transforms/IPO/PartialInlining.h"
#include "llvm/Transforms/IPO/SCCP.h"
#include "llvm/Transforms/IPO/StripDeadPrototypes.h"
diff --git a/lib/Passes/PassRegistry.def b/lib/Passes/PassRegistry.def
index 10cbf96284f..87eaae1c22c 100644
--- a/lib/Passes/PassRegistry.def
+++ b/lib/Passes/PassRegistry.def
@@ -50,6 +50,7 @@ MODULE_PASS("instrprof", InstrProfiling())
MODULE_PASS("internalize", InternalizePass())
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
MODULE_PASS("ipsccp", IPSCCPPass())
+MODULE_PASS("lowertypetests", LowerTypeTestsPass())
MODULE_PASS("no-op-module", NoOpModulePass())
MODULE_PASS("partial-inliner", PartialInlinerPass())
MODULE_PASS("pgo-icall-prom", PGOIndirectCallPromotion())
diff --git a/lib/Transforms/IPO/LowerTypeTests.cpp b/lib/Transforms/IPO/LowerTypeTests.cpp
index 67c9b971e35..36089f0a880 100644
--- a/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -985,25 +985,36 @@ bool LowerTypeTests::lower() {
return true;
}
+// Initialization helper shared by the old and the new PM.
+static void init(LowerTypeTests *LTT, Module &M) {
+ LTT->M = &M;
+ const DataLayout &DL = M.getDataLayout();
+ Triple TargetTriple(M.getTargetTriple());
+ LTT->LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX();
+ LTT->Arch = TargetTriple.getArch();
+ LTT->ObjectFormat = TargetTriple.getObjectFormat();
+ LTT->Int1Ty = Type::getInt1Ty(M.getContext());
+ LTT->Int8Ty = Type::getInt8Ty(M.getContext());
+ LTT->Int32Ty = Type::getInt32Ty(M.getContext());
+ LTT->Int32PtrTy = PointerType::getUnqual(LTT->Int32Ty);
+ LTT->Int64Ty = Type::getInt64Ty(M.getContext());
+ LTT->IntPtrTy = DL.getIntPtrType(M.getContext(), 0);
+ LTT->TypeTestCallSites.clear();
+}
+
bool LowerTypeTests::runOnModule(Module &M) {
if (skipModule(M))
return false;
-
- this->M = &M;
- const DataLayout &DL = M.getDataLayout();
-
- Triple TargetTriple(M.getTargetTriple());
- LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX();
- Arch = TargetTriple.getArch();
- ObjectFormat = TargetTriple.getObjectFormat();
-
- Int1Ty = Type::getInt1Ty(M.getContext());
- Int8Ty = Type::getInt8Ty(M.getContext());
- Int32Ty = Type::getInt32Ty(M.getContext());
- Int32PtrTy = PointerType::getUnqual(Int32Ty);
- Int64Ty = Type::getInt64Ty(M.getContext());
- IntPtrTy = DL.getIntPtrType(M.getContext(), 0);
-
- TypeTestCallSites.clear();
+ init(this, M);
return lower();
}
+
+PreservedAnalyses LowerTypeTestsPass::run(Module &M,
+ AnalysisManager<Module> &AM) {
+ LowerTypeTests Impl;
+ init(&Impl, M);
+ bool Changed = Impl.lower();
+ if (!Changed)
+ return PreservedAnalyses::all();
+ return PreservedAnalyses::none();
+}
diff --git a/test/Transforms/LowerTypeTests/constant.ll b/test/Transforms/LowerTypeTests/constant.ll
index 4ddf14916ba..65b21184d22 100644
--- a/test/Transforms/LowerTypeTests/constant.ll
+++ b/test/Transforms/LowerTypeTests/constant.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -lowertypetests < %s | FileCheck %s
+; RUN: opt -S -passes=lowertypetests < %s | FileCheck %s
target datalayout = "e-p:32:32"