Index: llvm/trunk/lib/Target/AMDGPU/AMDGPU.h =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AMDGPU.h +++ llvm/trunk/lib/Target/AMDGPU/AMDGPU.h @@ -93,7 +93,7 @@ ModulePass *createAMDGPUOpenCLImageTypeLoweringPass(); FunctionPass *createAMDGPUAnnotateUniformValues(); -FunctionPass* createAMDGPUUnifyMetadataPass(); +ModulePass* createAMDGPUUnifyMetadataPass(); void initializeAMDGPUUnifyMetadataPass(PassRegistry&); extern char &AMDGPUUnifyMetadataID; Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -208,7 +208,7 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) { Builder.addExtension( - PassManagerBuilder::EP_EarlyAsPossible, + PassManagerBuilder::EP_ModuleOptimizerEarly, [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) { PM.add(createAMDGPUUnifyMetadataPass()); }); Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp @@ -38,22 +38,14 @@ } // 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 @@ "Unify multiple OpenCL metadata due to linking", false, false) -FunctionPass* llvm::createAMDGPUUnifyMetadataPass() { +ModulePass* llvm::createAMDGPUUnifyMetadataPass() { return new AMDGPUUnifyMetadata(); } @@ -152,7 +144,3 @@ return Changed; } - -bool AMDGPUUnifyMetadata::runOnFunction(Function &F) { - return runOnModule(*F.getParent()); -} Index: llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll =================================================================== --- llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll +++ llvm/trunk/test/CodeGen/AMDGPU/unify-metadata.ll @@ -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}