mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-09 21:50:50 +00:00
Replace addEarlyAsPossiblePasses callback with adjustPassManager
This change introduces adjustPassManager target callback giving a target an opportunity to tweak PassManagerBuilder before pass managers are populated. This generalizes and replaces addEarlyAsPossiblePasses target callback. In particular that can be used to add custom passes to extension points other than EP_EarlyAsPossible. Differential Revision: https://reviews.llvm.org/D28336 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293189 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d9031ef908
commit
be4948cead
@ -34,6 +34,7 @@ class MCRegisterInfo;
|
||||
class MCSubtargetInfo;
|
||||
class MCSymbol;
|
||||
class raw_pwrite_stream;
|
||||
class PassManagerBuilder;
|
||||
class Target;
|
||||
class TargetIntrinsicInfo;
|
||||
class TargetIRAnalysis;
|
||||
@ -205,10 +206,9 @@ public:
|
||||
/// uses this to answer queries about the IR.
|
||||
virtual TargetIRAnalysis getTargetIRAnalysis();
|
||||
|
||||
/// Add target-specific function passes that should be run as early as
|
||||
/// possible in the optimization pipeline. Most TargetMachines have no such
|
||||
/// passes.
|
||||
virtual void addEarlyAsPossiblePasses(PassManagerBase &) {}
|
||||
/// Allow the target to modify the pass manager, e.g. by calling
|
||||
/// PassManagerBuilder::addExtension.
|
||||
virtual void adjustPassManager(PassManagerBuilder &) {}
|
||||
|
||||
/// These enums are meant to be passed into addPassesToEmitFile to indicate
|
||||
/// what type of file to emit, and returned by it to indicate what type of
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "llvm/Transforms/Vectorize.h"
|
||||
@ -205,8 +206,12 @@ StringRef AMDGPUTargetMachine::getFeatureString(const Function &F) const {
|
||||
FSAttr.getValueAsString();
|
||||
}
|
||||
|
||||
void AMDGPUTargetMachine::addEarlyAsPossiblePasses(PassManagerBase &PM) {
|
||||
PM.add(createAMDGPUUnifyMetadataPass());
|
||||
void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
|
||||
Builder.addExtension(
|
||||
PassManagerBuilder::EP_EarlyAsPossible,
|
||||
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
|
||||
PM.add(createAMDGPUUnifyMetadataPass());
|
||||
});
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -57,7 +57,8 @@ public:
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
}
|
||||
void addEarlyAsPossiblePasses(PassManagerBase &PM) override;
|
||||
|
||||
void adjustPassManager(PassManagerBuilder &) override;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "llvm/Transforms/Vectorize.h"
|
||||
@ -167,9 +168,13 @@ TargetPassConfig *NVPTXTargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
return new NVPTXPassConfig(this, PM);
|
||||
}
|
||||
|
||||
void NVPTXTargetMachine::addEarlyAsPossiblePasses(PassManagerBase &PM) {
|
||||
PM.add(createNVVMReflectPass());
|
||||
PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
|
||||
void NVPTXTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
|
||||
Builder.addExtension(
|
||||
PassManagerBuilder::EP_EarlyAsPossible,
|
||||
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
|
||||
PM.add(createNVVMReflectPass());
|
||||
PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
|
||||
});
|
||||
}
|
||||
|
||||
TargetIRAnalysis NVPTXTargetMachine::getTargetIRAnalysis() {
|
||||
|
@ -61,7 +61,8 @@ public:
|
||||
return TLOF.get();
|
||||
}
|
||||
|
||||
void addEarlyAsPossiblePasses(PassManagerBase &PM) override;
|
||||
void adjustPassManager(PassManagerBuilder &) override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
|
||||
}; // NVPTXTargetMachine.
|
||||
|
@ -287,13 +287,8 @@ static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
|
||||
Builder.SLPVectorize =
|
||||
DisableSLPVectorization ? false : OptLevel > 1 && SizeLevel < 2;
|
||||
|
||||
// Add target-specific passes that need to run as early as possible.
|
||||
if (TM)
|
||||
Builder.addExtension(
|
||||
PassManagerBuilder::EP_EarlyAsPossible,
|
||||
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
|
||||
TM->addEarlyAsPossiblePasses(PM);
|
||||
});
|
||||
TM->adjustPassManager(Builder);
|
||||
|
||||
if (Coroutines)
|
||||
addCoroutinePassesToExtensionPoints(Builder);
|
||||
|
Loading…
Reference in New Issue
Block a user