[llvm-branch-commits] [llvm] b8f22f9 - [NewPM][AMDGPU] Run InternalizePass when -amdgpu-internalize-symbols

Arthur Eubanks via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 4 11:42:19 PST 2021


Author: Arthur Eubanks
Date: 2021-01-04T11:34:40-08:00
New Revision: b8f22f9d3000b13c63a323bcf5230929191f402a

URL: https://github.com/llvm/llvm-project/commit/b8f22f9d3000b13c63a323bcf5230929191f402a
DIFF: https://github.com/llvm/llvm-project/commit/b8f22f9d3000b13c63a323bcf5230929191f402a.diff

LOG: [NewPM][AMDGPU] Run InternalizePass when -amdgpu-internalize-symbols

The legacy PM doesn't run EP_ModuleOptimizerEarly on -O0, so skip
running it here when given O0.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D93886

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    llvm/test/CodeGen/AMDGPU/internalize.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 7a09c91e62d7..6c730be97b9d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/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"
@@ -525,6 +527,17 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB,
     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) {

diff  --git a/llvm/test/CodeGen/AMDGPU/internalize.ll b/llvm/test/CodeGen/AMDGPU/internalize.ll
index 138b1c9cc605..8bdd3d450ccf 100644
--- a/llvm/test/CodeGen/AMDGPU/internalize.ll
+++ b/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


        


More information about the llvm-branch-commits mailing list