Skip to content

Commit

Permalink
[AMDGPU] Turn AMDGPUUnifyMetadata back into module pass
Browse files Browse the repository at this point in the history
With the adjustPassManager interface that is now possible to use
custom early module passes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293300 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rampitec committed Jan 27, 2017
1 parent 887da0d commit 1f3b497
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/Target/AMDGPU/AMDGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ModulePass *createAMDGPUAlwaysInlinePass();
ModulePass *createAMDGPUOpenCLImageTypeLoweringPass();
FunctionPass *createAMDGPUAnnotateUniformValues();

FunctionPass* createAMDGPUUnifyMetadataPass();
ModulePass* createAMDGPUUnifyMetadataPass();
void initializeAMDGPUUnifyMetadataPass(PassRegistry&);
extern char &AMDGPUUnifyMetadataID;

Expand Down
2 changes: 1 addition & 1 deletion lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ StringRef AMDGPUTargetMachine::getFeatureString(const Function &F) const {

void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.addExtension(
PassManagerBuilder::EP_EarlyAsPossible,
PassManagerBuilder::EP_ModuleOptimizerEarly,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createAMDGPUUnifyMetadataPass());
});
Expand Down
18 changes: 3 additions & 15 deletions lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +118,7 @@ INITIALIZE_PASS(AMDGPUUnifyMetadata, "amdgpu-unify-metadata",
"Unify multiple OpenCL metadata due to linking",
false, false)

FunctionPass* llvm::createAMDGPUUnifyMetadataPass() {
ModulePass* llvm::createAMDGPUUnifyMetadataPass() {
return new AMDGPUUnifyMetadata();
}

Expand All @@ -152,7 +144,3 @@ bool AMDGPUUnifyMetadata::runOnModule(Module &M) {

return Changed;
}

bool AMDGPUUnifyMetadata::runOnFunction(Function &F) {
return runOnModule(*F.getParent());
}
4 changes: 0 additions & 4 deletions test/CodeGen/AMDGPU/unify-metadata.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 1f3b497

Please sign in to comment.