[llvm] r293300 - [AMDGPU] Turn AMDGPUUnifyMetadata back into module pass

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 08:38:10 PST 2017


Author: rampitec
Date: Fri Jan 27 10:38:10 2017
New Revision: 293300

URL: http://llvm.org/viewvc/llvm-project?rev=293300&view=rev
Log:
[AMDGPU] Turn AMDGPUUnifyMetadata back into module pass

With the adjustPassManager interface that is now possible to use
custom early module passes.

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

Modified:
    llvm/trunk/lib/Target/AMDGPU/AMDGPU.h
    llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
    llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPU.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPU.h?rev=293300&r1=293299&r2=293300&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPU.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPU.h Fri Jan 27 10:38:10 2017
@@ -93,7 +93,7 @@ ModulePass *createAMDGPUAlwaysInlinePass
 ModulePass *createAMDGPUOpenCLImageTypeLoweringPass();
 FunctionPass *createAMDGPUAnnotateUniformValues();
 
-FunctionPass* createAMDGPUUnifyMetadataPass();
+ModulePass* createAMDGPUUnifyMetadataPass();
 void initializeAMDGPUUnifyMetadataPass(PassRegistry&);
 extern char &AMDGPUUnifyMetadataID;
 

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp?rev=293300&r1=293299&r2=293300&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp Fri Jan 27 10:38:10 2017
@@ -208,7 +208,7 @@ StringRef AMDGPUTargetMachine::getFeatur
 
 void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
   Builder.addExtension(
-    PassManagerBuilder::EP_EarlyAsPossible,
+    PassManagerBuilder::EP_ModuleOptimizerEarly,
     [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
       PM.add(createAMDGPUUnifyMetadataPass());
     });

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp?rev=293300&r1=293299&r2=293300&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp Fri Jan 27 10:38:10 2017
@@ -38,22 +38,14 @@ namespace {
   } // end namespace kOCLMD
 
   /// \brief Unify multiple OpenCL metadata due to linking.
-  class AMDGPUUnifyMetadata : public FunctionPass {
+  class AMDGPUUnifyMetadata : public ModulePass {
   public:
     static char ID;
-
-    explicit AMDGPUUnifyMetadata() : FunctionPass(ID) {}
+    explicit AMDGPUUnifyMetadata() : ModulePass(ID) {};
 
   private:
-    // This should really be a module pass but we have to run it as early
-    // as possible, so given function passes are executed first and
-    // TargetMachine::addEarlyAsPossiblePasses() expects only function passes
-    // it has to be a function pass.
     virtual bool runOnModule(Module &M);
 
-    // \todo: Convert to a module pass.
-    bool runOnFunction(Function &F) override;
-
     /// \brief Unify version metadata.
     /// \return true if changes are made.
     /// Assume the named metadata has operands each of which is a pair of
@@ -126,7 +118,7 @@ INITIALIZE_PASS(AMDGPUUnifyMetadata, "am
                 "Unify multiple OpenCL metadata due to linking",
                 false, false)
 
-FunctionPass* llvm::createAMDGPUUnifyMetadataPass() {
+ModulePass* llvm::createAMDGPUUnifyMetadataPass() {
   return new AMDGPUUnifyMetadata();
 }
 
@@ -152,7 +144,3 @@ bool AMDGPUUnifyMetadata::runOnModule(Mo
 
   return Changed;
 }
-
-bool AMDGPUUnifyMetadata::runOnFunction(Function &F) {
-  return runOnModule(*F.getParent());
-}

Modified: llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll?rev=293300&r1=293299&r2=293300&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll Fri Jan 27 10:38:10 2017
@@ -14,10 +14,6 @@
 ; ALL-DAG: ![[USED_EXT_1]] = !{!"cl_khr_fp16"}
 ; ALL-DAG: ![[USED_EXT_2]] = !{!"cl_doubles"}
 
-define void @test() {
-   ret void
-}
-
 !opencl.ocl.version = !{!1, !0, !0, !0}
 !llvm.ident = !{!2, !2, !2, !2, !6}
 !opencl.used.extensions = !{!3, !3, !4, !5}




More information about the llvm-commits mailing list