forked from OSchip/llvm-project
[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 llvm-svn: 299108
This commit is contained in:
parent
346dcaf1fa
commit
89653dfd2a
|
@ -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();
|
||||
|
||||
|
|
|
@ -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(Module &M) {
|
|||
}
|
||||
}
|
||||
|
||||
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(Module &M) {
|
|||
return false;
|
||||
}
|
||||
|
||||
ModulePass *llvm::createAMDGPUAlwaysInlinePass() {
|
||||
return new AMDGPUAlwaysInline();
|
||||
ModulePass *llvm::createAMDGPUAlwaysInlinePass(bool GlobalOpt) {
|
||||
return new AMDGPUAlwaysInline(GlobalOpt);
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
|
|||
PM.add(createGlobalDCEPass());
|
||||
}
|
||||
if (EarlyInline)
|
||||
PM.add(createAMDGPUAlwaysInlinePass());
|
||||
PM.add(createAMDGPUAlwaysInlinePass(false));
|
||||
});
|
||||
|
||||
Builder.addExtension(
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
; RUN: opt -mtriple=amdgcn-- -O1 -S -inline-threshold=1 -amdgpu-early-inline-all %s | FileCheck %s
|
||||
|
||||
; CHECK: @c_alias
|
||||
@c_alias = alias i32 (i32), i32 (i32)* @callee
|
||||
|
||||
define i32 @callee(i32 %x) {
|
||||
entry:
|
||||
%mul1 = mul i32 %x, %x
|
||||
|
|
Loading…
Reference in New Issue