Skip to content

Commit

Permalink
Parse pass options in opt/PassBuilder (#50383)
Browse files Browse the repository at this point in the history
  • Loading branch information
pchintalapudi authored Jul 1, 2023
1 parent 27e21c8 commit 36e188f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,19 @@ void registerCallbacks(PassBuilder &PB) JL_NOTSAFEPOINT {
#define FUNCTION_PASS(NAME, CLASS, CREATE_PASS) if (Name == NAME) { PM.addPass(CREATE_PASS); return true; }
#include "llvm-julia-passes.inc"
#undef FUNCTION_PASS
if (Name.consume_front("GCInvariantVerifier")) {
if (Name.consume_front("<") && Name.consume_back(">")) {
bool strong = true;
if (Name.consume_front("no-")) {
strong = false;
}
if (Name == "strong") {
PM.addPass(GCInvariantVerifierPass(strong));
return true;
}
}
return false;
}
return false;
});

Expand All @@ -839,6 +852,32 @@ void registerCallbacks(PassBuilder &PB) JL_NOTSAFEPOINT {
#define MODULE_PASS(NAME, CLASS, CREATE_PASS) if (Name == NAME) { PM.addPass(CREATE_PASS); return true; }
#include "llvm-julia-passes.inc"
#undef MODULE_PASS
if (Name.consume_front("LowerPTLSPass")) {
if (Name.consume_front("<") && Name.consume_back(">")) {
bool imaging_mode = true;
if (Name.consume_front("no-")) {
imaging_mode = false;
}
if (Name == "imaging") {
PM.addPass(LowerPTLSPass(imaging_mode));
return true;
}
}
return false;
}
if (Name.consume_front("JuliaMultiVersioning")) {
if (Name.consume_front("<") && Name.consume_back(">")) {
bool external_use = true;
if (Name.consume_front("no-")) {
external_use = false;
}
if (Name == "external") {
PM.addPass(MultiVersioningPass(external_use));
return true;
}
}
return false;
}
//Add full pipelines here
auto julia_options = parseJuliaPipelineOptions(Name);
if (julia_options) {
Expand Down
7 changes: 7 additions & 0 deletions test/llvmpasses/parsing.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; COM: NewPM-only test, tests for ability to parse Julia passes

; RUN: opt --opaque-pointers=0 --load-pass-plugin=libjulia-codegen%shlibext -passes='module(CPUFeatures,RemoveNI,LowerSIMDLoop,FinalLowerGC,JuliaMultiVersioning,RemoveJuliaAddrspaces,LowerPTLSPass,function(DemoteFloat16,CombineMulAdd,LateLowerGCFrame,AllocOpt,PropagateJuliaAddrspaces,LowerExcHandlers,GCInvariantVerifier,loop(JuliaLICM),GCInvariantVerifier<strong>,GCInvariantVerifier<no-strong>),LowerPTLSPass<imaging>,LowerPTLSPass<no-imaging>,JuliaMultiVersioning<external>,JuliaMultiVersioning<no-external>)' -S %s -o /dev/null

define void @test() {
ret void
}

0 comments on commit 36e188f

Please sign in to comment.