summaryrefslogtreecommitdiff
path: root/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
diff options
context:
space:
mode:
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2017-08-11 16:42:09 +0000
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2017-08-11 16:42:09 +0000
commit9643e6bd7823f74bf8898304d772250dcf8aaa1e (patch)
tree93ae95e5fe633935887e35a849c7c695ce95303e /lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
parentd457461f848a01aa6ed540fd1f60d045286b676c (diff)
[AMDGPU] Ported and adopted AMDLibCalls pass
The pass does simplifications of well known AMD library calls. If given -amdgpu-prelink option it works in a pre-link mode which allows to reference new library functions which will be linked in later. In addition it also used to process traditional AMD option -fuse-native which allows to replace some of the functions with their fast native implementations from the library. The necessary glue to pass the prelink option and translate -fuse-native is to be added to the driver. Differential Revision: https://reviews.llvm.org/D36436 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310731 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/AMDGPU/AMDGPUTargetMachine.cpp')
-rw-r--r--lib/Target/AMDGPU/AMDGPUTargetMachine.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 96e40cbc93b..1683ba0fb93 100644
--- a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -129,6 +129,13 @@ static cl::opt<bool> EnableAMDGPUFunctionCalls(
cl::desc("Enable AMDGPU function call support"),
cl::init(false));
+// Enable lib calls simplifications
+static cl::opt<bool> EnableLibCallSimplify(
+ "amdgpu-simplify-libcall",
+ cl::desc("Enable mdgpu library simplifications"),
+ cl::init(true),
+ cl::Hidden);
+
extern "C" void LLVMInitializeAMDGPUTarget() {
// Register the target
RegisterTargetMachine<R600TargetMachine> X(getTheAMDGPUTarget());
@@ -170,6 +177,8 @@ extern "C" void LLVMInitializeAMDGPUTarget() {
initializeSIFixWWMLivenessPass(*PR);
initializeAMDGPUUnifyDivergentExitNodesPass(*PR);
initializeAMDGPUAAWrapperPassPass(*PR);
+ initializeAMDGPUUseNativeCallsPass(*PR);
+ initializeAMDGPUSimplifyLibCallsPass(*PR);
}
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
@@ -313,12 +322,12 @@ static ImmutablePass *createAMDGPUExternalAAWrapperPass() {
void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.DivergentTarget = true;
- bool Internalize = InternalizeSymbols &&
- (getOptLevel() > CodeGenOpt::None) &&
+ bool EnableOpt = getOptLevel() > CodeGenOpt::None;
+ bool Internalize = InternalizeSymbols && EnableOpt &&
(getTargetTriple().getArch() == Triple::amdgcn);
- bool EarlyInline = EarlyInlineAll &&
- (getOptLevel() > CodeGenOpt::None);
- bool AMDGPUAA = EnableAMDGPUAliasAnalysis && getOptLevel() > CodeGenOpt::None;
+ bool EarlyInline = EarlyInlineAll && EnableOpt;
+ bool AMDGPUAA = EnableAMDGPUAliasAnalysis && EnableOpt;
+ bool LibCallSimplify = EnableLibCallSimplify && EnableOpt;
Builder.addExtension(
PassManagerBuilder::EP_ModuleOptimizerEarly,
@@ -357,11 +366,15 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.addExtension(
PassManagerBuilder::EP_EarlyAsPossible,
- [AMDGPUAA](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
+ [AMDGPUAA, LibCallSimplify](const PassManagerBuilder &,
+ legacy::PassManagerBase &PM) {
if (AMDGPUAA) {
PM.add(createAMDGPUAAWrapperPass());
PM.add(createAMDGPUExternalAAWrapperPass());
}
+ PM.add(llvm::createAMDGPUUseNativeCallsPass());
+ if (LibCallSimplify)
+ PM.add(llvm::createAMDGPUSimplifyLibCallsPass());
});
Builder.addExtension(