[PATCH] D93886: [NewPM][AMDGPU] Run InternalizePass when -amdgpu-internalize-symbols
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 28 20:34:22 PST 2020
aeubanks created this revision.
aeubanks added reviewers: arsenm, ychen.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
aeubanks requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
The legacy PM doesn't run EP_ModuleOptimizerEarly on -O0, so skip
running it here when given O0.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93886
Files:
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/test/CodeGen/AMDGPU/internalize.ll
Index: llvm/test/CodeGen/AMDGPU/internalize.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/internalize.ll
+++ llvm/test/CodeGen/AMDGPU/internalize.ll
@@ -1,5 +1,7 @@
-; RUN: opt -O1 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
; RUN: opt -O0 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPTNONE %s
+; RUN: opt -passes='default<O0>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPTNONE %s
+; RUN: opt -O1 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
+; RUN: opt -passes='default<O1>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
; OPT-NOT: gvar_unused
; OPTNONE: gvar_unused
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -51,6 +51,8 @@
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/AlwaysInliner.h"
+#include "llvm/Transforms/IPO/GlobalDCE.h"
+#include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h"
@@ -521,6 +523,17 @@
PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
});
+ PB.registerPipelineEarlySimplificationEPCallback(
+ [](ModulePassManager &PM, PassBuilder::OptimizationLevel Level) {
+ if (Level == PassBuilder::OptimizationLevel::O0)
+ return;
+
+ if (InternalizeSymbols) {
+ PM.addPass(InternalizePass(mustPreserveGV));
+ PM.addPass(GlobalDCEPass());
+ }
+ });
+
PB.registerCGSCCOptimizerLateEPCallback(
[this, DebugPassManager](CGSCCPassManager &PM,
PassBuilder::OptimizationLevel Level) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93886.313932.patch
Type: text/x-patch
Size: 2207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201229/83b316fe/attachment.bin>
More information about the llvm-commits
mailing list