Compare commits
1 Commits
jit-next-g
...
code-motio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3651cdec4 |
@@ -71,6 +71,7 @@ void initializeAssumeBuilderPassLegacyPassPass(PassRegistry &);
|
|||||||
void initializeAnnotation2MetadataLegacyPass(PassRegistry &);
|
void initializeAnnotation2MetadataLegacyPass(PassRegistry &);
|
||||||
void initializeAnnotationRemarksLegacyPass(PassRegistry &);
|
void initializeAnnotationRemarksLegacyPass(PassRegistry &);
|
||||||
void initializeOpenMPOptCGSCCLegacyPassPass(PassRegistry &);
|
void initializeOpenMPOptCGSCCLegacyPassPass(PassRegistry &);
|
||||||
|
void initializeCommunicationOptCGSCCLegacyPassPass(PassRegistry &);
|
||||||
void initializeArgPromotionPass(PassRegistry&);
|
void initializeArgPromotionPass(PassRegistry&);
|
||||||
void initializeAssumptionCacheTrackerPass(PassRegistry&);
|
void initializeAssumptionCacheTrackerPass(PassRegistry&);
|
||||||
void initializeAtomicExpandPass(PassRegistry&);
|
void initializeAtomicExpandPass(PassRegistry&);
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ Pass *createArgumentPromotionPass(unsigned maxElements = 3);
|
|||||||
/// createOpenMPOptLegacyPass - OpenMP specific optimizations.
|
/// createOpenMPOptLegacyPass - OpenMP specific optimizations.
|
||||||
Pass *createOpenMPOptCGSCCLegacyPass();
|
Pass *createOpenMPOptCGSCCLegacyPass();
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
/// createCommunicationOptCGSCCLegacyPass - Communication code motion
|
||||||
|
/// optimizations.
|
||||||
|
Pass *createCommunicationOptCGSCCLegacyPass();
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// createIPSCCPPass - This pass propagates constants from call sites into the
|
/// createIPSCCPPass - This pass propagates constants from call sites into the
|
||||||
/// bodies of functions, and keeps track of whether basic blocks are executable
|
/// bodies of functions, and keeps track of whether basic blocks are executable
|
||||||
|
|||||||
33
llvm/include/llvm/Transforms/IPO/CommunicationOpt.h
Normal file
33
llvm/include/llvm/Transforms/IPO/CommunicationOpt.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
//===- CommunicationOpt.h - Communication optimizations ---------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_TRANSFORMS_IPO_COMMUNICATION_H
|
||||||
|
#define LLVM_TRANSFORMS_IPO_COMMUNICATION_H
|
||||||
|
|
||||||
|
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||||
|
#include "llvm/Analysis/LazyCallGraph.h"
|
||||||
|
#include "llvm/IR/PassManager.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
/// Communication optimizations pass.
|
||||||
|
class CommunicationOptPass : public PassInfoMixin<CommunicationOptPass> {
|
||||||
|
public:
|
||||||
|
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CommunicationOptCGSCCPass
|
||||||
|
: public PassInfoMixin<CommunicationOptCGSCCPass> {
|
||||||
|
public:
|
||||||
|
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
|
||||||
|
LazyCallGraph &CG, CGSCCUpdateResult &UR);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
#endif // LLVM_TRANSFORMS_IPO_COMMUNICATION_H
|
||||||
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMipo
|
|||||||
BarrierNoopPass.cpp
|
BarrierNoopPass.cpp
|
||||||
BlockExtractor.cpp
|
BlockExtractor.cpp
|
||||||
CalledValuePropagation.cpp
|
CalledValuePropagation.cpp
|
||||||
|
CommunicationOpt.cpp
|
||||||
ConstantMerge.cpp
|
ConstantMerge.cpp
|
||||||
CrossDSOCFI.cpp
|
CrossDSOCFI.cpp
|
||||||
DeadArgumentElimination.cpp
|
DeadArgumentElimination.cpp
|
||||||
|
|||||||
87
llvm/lib/Transforms/IPO/CommunicationOpt.cpp
Normal file
87
llvm/lib/Transforms/IPO/CommunicationOpt.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
//===-- CommunicationOpt.cpp - Collection of communication optimizations --===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Communication optimization.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Transforms/IPO/CommunicationOpt.h"
|
||||||
|
|
||||||
|
#include "llvm/Analysis/CallGraph.h"
|
||||||
|
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||||
|
#include "llvm/InitializePasses.h"
|
||||||
|
#include "llvm/Transforms/IPO.h"
|
||||||
|
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
#define DEBUG_TYPE "communication-opt"
|
||||||
|
|
||||||
|
#if !defined(NDEBUG)
|
||||||
|
static constexpr auto TAG = "[" DEBUG_TYPE "]";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class CommunicationOpt {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct CommunicationOptCGSCCLegacyPass : public CallGraphSCCPass {
|
||||||
|
CallGraphUpdater CGUpdater;
|
||||||
|
static char ID;
|
||||||
|
|
||||||
|
CommunicationOptCGSCCLegacyPass() : CallGraphSCCPass(ID) {
|
||||||
|
initializeCommunicationOptCGSCCLegacyPassPass(
|
||||||
|
*PassRegistry::getPassRegistry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
CallGraphSCCPass::getAnalysisUsage(AU);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool runOnSCC(CallGraphSCC &CGSCC) override {
|
||||||
|
SmallVector<Function *, 16> SCC;
|
||||||
|
for (CallGraphNode *CGN : CGSCC) {
|
||||||
|
Function *Fn = CGN->getFunction();
|
||||||
|
if (!Fn || Fn->isDeclaration())
|
||||||
|
continue;
|
||||||
|
SCC.push_back(Fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCC.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Module &M = CGSCC.getCallGraph().getModule();
|
||||||
|
CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
|
||||||
|
CGUpdater.initialize(CG, CGSCC);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool doFinalization(CallGraph &CG) override { return CGUpdater.finalize(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
char CommunicationOptCGSCCLegacyPass::ID = 0;
|
||||||
|
|
||||||
|
INITIALIZE_PASS_BEGIN(CommunicationOptCGSCCLegacyPass,
|
||||||
|
"communication-opt-cgscc",
|
||||||
|
"Communication code motion optimizations", false, false)
|
||||||
|
INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
|
||||||
|
INITIALIZE_PASS_END(CommunicationOptCGSCCLegacyPass, "communication-opt-cgscc",
|
||||||
|
"Communication code motion optimizations", false, false)
|
||||||
|
|
||||||
|
Pass *llvm::createCommunicationOptCGSCCLegacyPass() {
|
||||||
|
return new CommunicationOptCGSCCLegacyPass();
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ using namespace llvm;
|
|||||||
|
|
||||||
void llvm::initializeIPO(PassRegistry &Registry) {
|
void llvm::initializeIPO(PassRegistry &Registry) {
|
||||||
initializeOpenMPOptCGSCCLegacyPassPass(Registry);
|
initializeOpenMPOptCGSCCLegacyPassPass(Registry);
|
||||||
|
initializeCommunicationOptCGSCCLegacyPassPass(Registry);
|
||||||
initializeArgPromotionPass(Registry);
|
initializeArgPromotionPass(Registry);
|
||||||
initializeAnnotation2MetadataLegacyPass(Registry);
|
initializeAnnotation2MetadataLegacyPass(Registry);
|
||||||
initializeCalledValuePropagationLegacyPassPass(Registry);
|
initializeCalledValuePropagationLegacyPassPass(Registry);
|
||||||
|
|||||||
Reference in New Issue
Block a user