Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport https://github.com/JuliaLang/julia/pull/55407 to 1.11 #55433

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -553,7 +553,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 @@ -618,65 +618,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 @@ -862,6 +803,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
5 changes: 4 additions & 1 deletion 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 --opaque-pointers=0 --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='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