diff options
author | Justin Lebar <jlebar@google.com> | 2016-04-27 19:13:37 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-04-27 19:13:37 +0000 |
commit | 7cdbce59462d87c7e8236ef9032b9ec11e2d54a4 (patch) | |
tree | 45d2015557650557034076ed8ba556f86e7142e7 | |
parent | 5a7df9c130410766a3e76423109bafae1abbae3d (diff) | |
download | bcm5719-llvm-7cdbce59462d87c7e8236ef9032b9ec11e2d54a4.tar.gz bcm5719-llvm-7cdbce59462d87c7e8236ef9032b9ec11e2d54a4.zip |
[NVPTX] Run NVVMReflect at the beginning of IR passes.
Summary:
Currently the NVVMReflect pass is run at the beginning of our backend
passes. But really, it should be run as early as possible, as it's
simply resolving an "if" statement in code. So copy it into
TargetMachine::addEarlyAsPossiblePasses.
We still run it at the beginning of the backend passes, since it's
needed for correctness when lowering to nvptx.
(Specifically, NVVMReflect changes each call to the __nvvm_reflect
function or llvm.nvvm.reflect intrinsic into an integer constant, based
on the pass's configuration. Clearly we miss many optimization
opportunities if we perform this transformation at the beginning of
codegen.)
Reviewers: rnk
Subscribers: tra, llvm-commits, jholewinski
Differential Revision: http://reviews.llvm.org/D18616
llvm-svn: 267765
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXTargetMachine.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp index b28aa767ce5..06a9253ee02 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -167,6 +167,10 @@ TargetPassConfig *NVPTXTargetMachine::createPassConfig(PassManagerBase &PM) { return new NVPTXPassConfig(this, PM); } +void NVPTXTargetMachine::addEarlyAsPossiblePasses(PassManagerBase &PM) { + PM.add(createNVVMReflectPass()); +} + TargetIRAnalysis NVPTXTargetMachine::getTargetIRAnalysis() { return TargetIRAnalysis([this](const Function &F) { return TargetTransformInfo(NVPTXTTIImpl(this, F)); @@ -228,7 +232,12 @@ void NVPTXPassConfig::addIRPasses() { disablePass(&FuncletLayoutID); disablePass(&PatchableFunctionID); + // NVVMReflectPass is added in addEarlyAsPossiblePasses, so hopefully running + // it here does nothing. But since we need it for correctness when lowering + // to NVPTX, run it here too, in case whoever built our pass pipeline didn't + // call addEarlyAsPossiblePasses. addPass(createNVVMReflectPass()); + if (getOptLevel() != CodeGenOpt::None) addPass(createNVPTXImageOptimizerPass()); addPass(createNVPTXAssignValidGlobalNamesPass()); diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h index 9da7bc46acc..f92478216b2 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h @@ -61,6 +61,7 @@ public: return TLOF.get(); } + void addEarlyAsPossiblePasses(PassManagerBase &PM) override; TargetIRAnalysis getTargetIRAnalysis() override; }; // NVPTXTargetMachine. |