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

Make warn missed transformations pass optional #54871

Merged
merged 1 commit into from
Jul 18, 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
6 changes: 4 additions & 2 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct OptimizationOptions {
bool enable_vector_pipeline;
bool remove_ni;
bool cleanup;
bool warn_missed_transformations;

static constexpr OptimizationOptions defaults(
bool lower_intrinsics=true,
Expand All @@ -103,12 +104,13 @@ struct OptimizationOptions {
bool enable_loop_optimizations=true,
bool enable_vector_pipeline=true,
bool remove_ni=true,
bool cleanup=true) {
bool cleanup=true,
bool warn_missed_transformations=false) {
return {lower_intrinsics, dump_native, external_use, llvm_only,
always_inline, enable_early_simplifications,
enable_early_optimizations, enable_scalar_optimizations,
enable_loop_optimizations, enable_vector_pipeline,
remove_ni, cleanup};
remove_ni, cleanup, warn_missed_transformations};
}
};

Expand Down
10 changes: 7 additions & 3 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ static void buildPipeline(ModulePassManager &MPM, PassBuilder *PB, OptimizationL
if (O.getSpeedupLevel() >= 2) {
buildVectorPipeline(FPM, PB, O, options);
}
FPM.addPass(WarnMissedTransformationsPass());
if (options.warn_missed_transformations)
FPM.addPass(WarnMissedTransformationsPass());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
buildIntrinsicLoweringPipeline(MPM, PB, O, options);
Expand All @@ -632,6 +633,7 @@ struct PipelineConfig {
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
Expand Down Expand Up @@ -672,7 +674,8 @@ extern "C" JL_DLLEXPORT_CODEGEN void jl_build_newpm_pipeline_impl(void *MPM, voi
!!config->enable_loop_optimizations,
!!config->enable_vector_pipeline,
!!config->remove_ni,
!!config->cleanup});
!!config->cleanup,
!!config->warn_missed_transformations});
}

#undef JULIA_PASS
Expand Down Expand Up @@ -870,7 +873,8 @@ static Optional<std::pair<OptimizationLevel, OptimizationOptions>> parseJuliaPip
OPTION(lower_intrinsics),
OPTION(dump_native),
OPTION(external_use),
OPTION(llvm_only)
OPTION(llvm_only),
OPTION(warn_missed_transformations)
#undef OPTION
};
while (!name.empty()) {
Expand Down
20 changes: 20 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1547,3 +1547,23 @@ end
@testset "Base.Libc docstrings" begin
@test isempty(Docs.undocumented_names(Libc))
end

@testset "Silenced missed transformations" begin
# Ensure the WarnMissedTransformationsPass is not on by default
src = """
@noinline iteration(i) = (@show(i); return nothing)
@eval function loop_unroll_full_fail(N)
for i in 1:N
iteration(i)
\$(Expr(:loopinfo, (Symbol("llvm.loop.unroll.full"), 1)))
end
end
loop_unroll_full_fail(3)
"""
out_err = mktemp() do _, f
run(`$(Base.julia_cmd()) -e "$src"`, devnull, devnull, f)
seekstart(f)
read(f, String)
end
@test !occursin("loop not unrolled", out_err)
end