[llvm] r299108 - [AMDGPU] Add GlobalOpt parameter to Always Inliner pass
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 13:16:02 PDT 2017
Author: rampitec
Date: Thu Mar 30 15:16:02 2017
New Revision: 299108
URL: http://llvm.org/viewvc/llvm-project?rev=299108&view=rev
Log:
[AMDGPU] Add GlobalOpt parameter to Always Inliner pass
If set to false it does not remove global aliases. With this parameter
set to false it should be safe to run the pass before link.
Differential Revision: https://reviews.llvm.org/D31489
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPU.h
llvm/trunk/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/trunk/test/CodeGen/AMDGPU/early-inline.ll
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPU.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPU.h?rev=299108&r1=299107&r2=299108&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPU.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPU.h Thu Mar 30 15:16:02 2017
@@ -98,7 +98,7 @@ extern char &AMDGPUPromoteAllocaID;
Pass *createAMDGPUStructurizeCFGPass();
FunctionPass *createAMDGPUISelDag(TargetMachine &TM,
CodeGenOpt::Level OptLevel);
-ModulePass *createAMDGPUAlwaysInlinePass();
+ModulePass *createAMDGPUAlwaysInlinePass(bool GlobalOpt = true);
ModulePass *createAMDGPUOpenCLImageTypeLoweringPass();
FunctionPass *createAMDGPUAnnotateUniformValues();
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp?rev=299108&r1=299107&r2=299108&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp Thu Mar 30 15:16:02 2017
@@ -24,8 +24,10 @@ namespace {
class AMDGPUAlwaysInline : public ModulePass {
static char ID;
+ bool GlobalOpt;
+
public:
- AMDGPUAlwaysInline() : ModulePass(ID) { }
+ AMDGPUAlwaysInline(bool GlobalOpt) : ModulePass(ID), GlobalOpt(GlobalOpt) { }
bool runOnModule(Module &M) override;
StringRef getPassName() const override { return "AMDGPU Always Inline Pass"; }
};
@@ -45,8 +47,10 @@ bool AMDGPUAlwaysInline::runOnModule(Mod
}
}
- for (GlobalAlias* A : AliasesToRemove) {
- A->eraseFromParent();
+ if (GlobalOpt) {
+ for (GlobalAlias* A : AliasesToRemove) {
+ A->eraseFromParent();
+ }
}
for (Function &F : M) {
@@ -70,6 +74,6 @@ bool AMDGPUAlwaysInline::runOnModule(Mod
return false;
}
-ModulePass *llvm::createAMDGPUAlwaysInlinePass() {
- return new AMDGPUAlwaysInline();
+ModulePass *llvm::createAMDGPUAlwaysInlinePass(bool GlobalOpt) {
+ return new AMDGPUAlwaysInline(GlobalOpt);
}
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp?rev=299108&r1=299107&r2=299108&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp Thu Mar 30 15:16:02 2017
@@ -315,7 +315,7 @@ void AMDGPUTargetMachine::adjustPassMana
PM.add(createGlobalDCEPass());
}
if (EarlyInline)
- PM.add(createAMDGPUAlwaysInlinePass());
+ PM.add(createAMDGPUAlwaysInlinePass(false));
});
Builder.addExtension(
Modified: llvm/trunk/test/CodeGen/AMDGPU/early-inline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/early-inline.ll?rev=299108&r1=299107&r2=299108&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/early-inline.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/early-inline.ll Thu Mar 30 15:16:02 2017
@@ -1,5 +1,8 @@
; RUN: opt -mtriple=amdgcn-- -O1 -S -inline-threshold=1 -amdgpu-early-inline-all %s | FileCheck %s
+; CHECK: @c_alias
+ at c_alias = alias i32 (i32), i32 (i32)* @callee
+
define i32 @callee(i32 %x) {
entry:
%mul1 = mul i32 %x, %x
More information about the llvm-commits
mailing list