Skip to content

Commit

Permalink
Remove deprecated non string API for LLVM pass pipeline and parse all…
Browse files Browse the repository at this point in the history
… options (JuliaLang#55407)

This technically removes the option for Oz in julia but it doesn't
actually do what one wants.
This removes an API currently used by Enzyme.jl and AllocCheck.jl but
given that LLVM.jl doesn't support this API anymore that seems fine.
@wsmoses @maleadt
Do we want the replacement for this (a function that parses the
PipelineConfig struct) to live in LLVM.jl or GPUCompiler.jl ?
  • Loading branch information
gbaraldi authored and lazarusA committed Aug 17, 2024
1 parent 9dcbff2 commit 4e2c775
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 62 deletions.
2 changes: 0 additions & 2 deletions src/codegen-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ JL_DLLEXPORT uint64_t jl_getUnwindInfo_fallback(uint64_t dwAddr)
return 0;
}

JL_DLLEXPORT void jl_build_newpm_pipeline_fallback(void *MPM, void *PB, void *config) UNAVAILABLE

JL_DLLEXPORT void jl_register_passbuilder_callbacks_fallback(void *PB) { }

#define MODULE_PASS(NAME, CLASS, CREATE_PASS) \
Expand Down
1 change: 0 additions & 1 deletion src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@
YY(jl_type_to_llvm) \
YY(jl_getUnwindInfo) \
YY(jl_get_libllvm) \
YY(jl_build_newpm_pipeline) \
YY(jl_register_passbuilder_callbacks) \
YY(LLVMExtraMPMAddCPUFeaturesPass) \
YY(LLVMExtraMPMAddRemoveNIPass) \
Expand Down
67 changes: 8 additions & 59 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,65 +609,6 @@ static void buildPipeline(ModulePassManager &MPM, PassBuilder *PB, OptimizationL
MPM.addPass(AfterOptimizationMarkerPass());
}

struct PipelineConfig {
int Speedup;
int Size;
int lower_intrinsics;
int dump_native;
int external_use;
int llvm_only;
int always_inline;
int enable_early_simplifications;
int enable_early_optimizations;
int enable_scalar_optimizations;
int enable_loop_optimizations;
int enable_vector_pipeline;
int remove_ni;
int cleanup;
int warn_missed_transformations;
};

extern "C" JL_DLLEXPORT_CODEGEN void jl_build_newpm_pipeline_impl(void *MPM, void *PB, PipelineConfig* config) JL_NOTSAFEPOINT
{
OptimizationLevel O;
switch (config->Size) {
case 1:
O = OptimizationLevel::Os;
break;
default:
O = OptimizationLevel::Oz;
break;
case 0:
switch (config->Speedup) {
case 0:
O = OptimizationLevel::O0;
break;
case 1:
O = OptimizationLevel::O1;
break;
case 2:
O = OptimizationLevel::O2;
break;
default:
O = OptimizationLevel::O3;
break;
}
}
buildPipeline(*reinterpret_cast<ModulePassManager*>(MPM), reinterpret_cast<PassBuilder*>(PB), O,
OptimizationOptions{!!config->lower_intrinsics,
!!config->dump_native,
!!config->external_use,
!!config->llvm_only,
!!config->always_inline,
!!config->enable_early_simplifications,
!!config->enable_early_optimizations,
!!config->enable_scalar_optimizations,
!!config->enable_loop_optimizations,
!!config->enable_vector_pipeline,
!!config->remove_ni,
!!config->cleanup,
!!config->warn_missed_transformations});
}

#undef JULIA_PASS

Expand Down Expand Up @@ -865,6 +806,14 @@ static Optional<std::pair<OptimizationLevel, OptimizationOptions>> parseJuliaPip
OPTION(dump_native),
OPTION(external_use),
OPTION(llvm_only),
OPTION(always_inline),
OPTION(enable_early_simplifications),
OPTION(enable_early_optimizations),
OPTION(enable_scalar_optimizations),
OPTION(enable_loop_optimizations),
OPTION(enable_vector_pipeline),
OPTION(remove_ni),
OPTION(cleanup),
OPTION(warn_missed_transformations)
#undef OPTION
};
Expand Down
3 changes: 3 additions & 0 deletions test/llvmpasses/parsing.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; COM: NewPM-only test, tests for ability to parse Julia passes

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

define void @test() {
ret void
Expand Down

0 comments on commit 4e2c775

Please sign in to comment.