[llvm] r343662 - Add support for new pass manager
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 2 22:55:20 PDT 2018
Author: hiraditya
Date: Tue Oct 2 22:55:20 2018
New Revision: 343662
URL: http://llvm.org/viewvc/llvm-project?rev=343662&view=rev
Log:
Add support for new pass manager
Modified the testcases to use both pass managers
Use single commandline flag for both pass managers.
Differential Revision: https://reviews.llvm.org/D52708
Reviewers: sebpop, tejohnson, brzycki, SirishP
Reviewed By: tejohnson, brzycki
Added:
llvm/trunk/include/llvm/Transforms/IPO/HotColdSplitting.h
Modified:
llvm/trunk/lib/Passes/PassBuilder.cpp
llvm/trunk/lib/Passes/PassRegistry.def
llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/trunk/test/Transforms/HotColdSplit/split-cold-1.ll
llvm/trunk/test/Transforms/HotColdSplit/split-cold-2.ll
Added: llvm/trunk/include/llvm/Transforms/IPO/HotColdSplitting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/HotColdSplitting.h?rev=343662&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/HotColdSplitting.h (added)
+++ llvm/trunk/include/llvm/Transforms/IPO/HotColdSplitting.h Tue Oct 2 22:55:20 2018
@@ -0,0 +1,31 @@
+//===- HotColdSplitting.h ---- Outline Cold Regions -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===----------------------------------------------------------------------===//
+//
+// This pass outlines cold regions to a separate function.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
+#define LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Module;
+
+/// Pass to outline cold regions.
+class HotColdSplittingPass : public PassInfoMixin<HotColdSplittingPass> {
+public:
+ PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_HOTCOLDSPLITTING_H
+
Modified: llvm/trunk/lib/Passes/PassBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassBuilder.cpp?rev=343662&r1=343661&r2=343662&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp (original)
+++ llvm/trunk/lib/Passes/PassBuilder.cpp Tue Oct 2 22:55:20 2018
@@ -75,6 +75,7 @@
#include "llvm/Transforms/IPO/GlobalDCE.h"
#include "llvm/Transforms/IPO/GlobalOpt.h"
#include "llvm/Transforms/IPO/GlobalSplit.h"
+#include "llvm/Transforms/IPO/HotColdSplitting.h"
#include "llvm/Transforms/IPO/InferFunctionAttrs.h"
#include "llvm/Transforms/IPO/Inliner.h"
#include "llvm/Transforms/IPO/Internalize.h"
@@ -198,6 +199,8 @@ static cl::opt<bool>
EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
cl::desc("Enable control height reduction optimization (CHR)"));
+extern cl::opt<bool> EnableHotColdSplit;
+
static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level) {
switch (Level) {
case PassBuilder::O0:
@@ -614,6 +617,9 @@ PassBuilder::buildModuleSimplificationPi
true));
}
+ if (EnableHotColdSplit)
+ MPM.addPass(HotColdSplittingPass());
+
// Interprocedural constant propagation now that basic cleanup has occurred
// and prior to optimizing globals.
// FIXME: This position in the pipeline hasn't been carefully considered in
Modified: llvm/trunk/lib/Passes/PassRegistry.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassRegistry.def?rev=343662&r1=343661&r2=343662&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassRegistry.def (original)
+++ llvm/trunk/lib/Passes/PassRegistry.def Tue Oct 2 22:55:20 2018
@@ -51,6 +51,7 @@ MODULE_PASS("function-import", FunctionI
MODULE_PASS("globaldce", GlobalDCEPass())
MODULE_PASS("globalopt", GlobalOptPass())
MODULE_PASS("globalsplit", GlobalSplitPass())
+MODULE_PASS("hotcoldsplit", HotColdSplittingPass())
MODULE_PASS("inferattrs", InferFunctionAttrsPass())
MODULE_PASS("insert-gcov-profiling", GCOVProfilerPass())
MODULE_PASS("instrprof", InstrProfiling())
Modified: llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp?rev=343662&r1=343661&r2=343662&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp Tue Oct 2 22:55:20 2018
@@ -44,6 +44,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/IPO/HotColdSplitting.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
@@ -409,6 +410,38 @@ bool HotColdSplittingLegacyPass::runOnMo
return HotColdSplitting(PSI, GBFI, GTTI, &GetORE).run(M);
}
+PreservedAnalyses
+HotColdSplittingPass::run(Module &M, ModuleAnalysisManager &AM) {
+ auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+
+ std::function<AssumptionCache &(Function &)> GetAssumptionCache =
+ [&FAM](Function &F) -> AssumptionCache & {
+ return FAM.getResult<AssumptionAnalysis>(F);
+ };
+
+ auto GBFI = [&FAM](Function &F) {
+ return &FAM.getResult<BlockFrequencyAnalysis>(F);
+ };
+
+ std::function<TargetTransformInfo &(Function &)> GTTI =
+ [&FAM](Function &F) -> TargetTransformInfo & {
+ return FAM.getResult<TargetIRAnalysis>(F);
+ };
+
+ std::unique_ptr<OptimizationRemarkEmitter> ORE;
+ std::function<OptimizationRemarkEmitter &(Function &)> GetORE =
+ [&ORE](Function &F) -> OptimizationRemarkEmitter & {
+ ORE.reset(new OptimizationRemarkEmitter(&F));
+ return *ORE.get();
+ };
+
+ ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
+
+ if (HotColdSplitting(PSI, GBFI, GTTI, &GetORE).run(M))
+ return PreservedAnalyses::none();
+ return PreservedAnalyses::all();
+}
+
char HotColdSplittingLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(HotColdSplittingLegacyPass, "hotcoldsplit",
"Hot Cold Splitting", false, false)
Modified: llvm/trunk/test/Transforms/HotColdSplit/split-cold-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/split-cold-1.ll?rev=343662&r1=343661&r2=343662&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/split-cold-1.ll (original)
+++ llvm/trunk/test/Transforms/HotColdSplit/split-cold-1.ll Tue Oct 2 22:55:20 2018
@@ -1,4 +1,5 @@
; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -passes=hotcoldsplit -S < %s | FileCheck %s
; Outlined function is called from a basic block named codeRepl
; CHECK: codeRepl:
Modified: llvm/trunk/test/Transforms/HotColdSplit/split-cold-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/split-cold-2.ll?rev=343662&r1=343661&r2=343662&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/split-cold-2.ll (original)
+++ llvm/trunk/test/Transforms/HotColdSplit/split-cold-2.ll Tue Oct 2 22:55:20 2018
@@ -1,4 +1,5 @@
; RUN: opt -hotcoldsplit -S < %s
+; RUN: opt -passes=hotcoldsplit -S < %s
; Make sure this compiles. This test used to fail with an invalid phi node: the
; two predecessors were outlined and the SSA representation was invalid.
More information about the llvm-commits
mailing list