Skip to content

Commit 5cf0a8f

Browse files
committed
Make warn missed transformations optional
This makes the `WarnMissedTransformationsPass` compiler pass optional and off by default.
1 parent 06b4142 commit 5cf0a8f

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

src/jitlayers.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct OptimizationOptions {
9090
bool enable_vector_pipeline;
9191
bool remove_ni;
9292
bool cleanup;
93+
bool warn_missed_transformations;
9394

9495
static constexpr OptimizationOptions defaults(
9596
bool lower_intrinsics=true,
@@ -103,12 +104,13 @@ struct OptimizationOptions {
103104
bool enable_loop_optimizations=true,
104105
bool enable_vector_pipeline=true,
105106
bool remove_ni=true,
106-
bool cleanup=true) {
107+
bool cleanup=true,
108+
bool warn_missed_transformations=false) {
107109
return {lower_intrinsics, dump_native, external_use, llvm_only,
108110
always_inline, enable_early_simplifications,
109111
enable_early_optimizations, enable_scalar_optimizations,
110112
enable_loop_optimizations, enable_vector_pipeline,
111-
remove_ni, cleanup};
113+
remove_ni, cleanup, warn_missed_transformations};
112114
}
113115
};
114116

src/pipeline.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ static void buildPipeline(ModulePassManager &MPM, PassBuilder *PB, OptimizationL
609609
if (O.getSpeedupLevel() >= 2) {
610610
buildVectorPipeline(FPM, PB, O, options);
611611
}
612-
FPM.addPass(WarnMissedTransformationsPass());
612+
if (options.warn_missed_transformations)
613+
FPM.addPass(WarnMissedTransformationsPass());
613614
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
614615
}
615616
buildIntrinsicLoweringPipeline(MPM, PB, O, options);
@@ -632,6 +633,7 @@ struct PipelineConfig {
632633
int enable_vector_pipeline;
633634
int remove_ni;
634635
int cleanup;
636+
int warn_missed_transformations;
635637
};
636638

637639
extern "C" JL_DLLEXPORT_CODEGEN void jl_build_newpm_pipeline_impl(void *MPM, void *PB, PipelineConfig* config) JL_NOTSAFEPOINT
@@ -672,7 +674,8 @@ extern "C" JL_DLLEXPORT_CODEGEN void jl_build_newpm_pipeline_impl(void *MPM, voi
672674
!!config->enable_loop_optimizations,
673675
!!config->enable_vector_pipeline,
674676
!!config->remove_ni,
675-
!!config->cleanup});
677+
!!config->cleanup,
678+
!!config->warn_missed_transformations});
676679
}
677680

678681
#undef JULIA_PASS
@@ -870,7 +873,8 @@ static Optional<std::pair<OptimizationLevel, OptimizationOptions>> parseJuliaPip
870873
OPTION(lower_intrinsics),
871874
OPTION(dump_native),
872875
OPTION(external_use),
873-
OPTION(llvm_only)
876+
OPTION(llvm_only),
877+
OPTION(warn_missed_transformations)
874878
#undef OPTION
875879
};
876880
while (!name.empty()) {

test/misc.jl

+20
Original file line numberDiff line numberDiff line change
@@ -1547,3 +1547,23 @@ end
15471547
@testset "Base.Libc docstrings" begin
15481548
@test isempty(Docs.undocumented_names(Libc))
15491549
end
1550+
1551+
@testset "Silenced missed transformations" begin
1552+
# Ensure the WarnMissedTransformationsPass is not on by default
1553+
src = """
1554+
@noinline iteration(i) = (@show(i); return nothing)
1555+
@eval function loop_unroll_full_fail(N)
1556+
for i in 1:N
1557+
iteration(i)
1558+
\$(Expr(:loopinfo, (Symbol("llvm.loop.unroll.full"), 1)))
1559+
end
1560+
end
1561+
loop_unroll_full_fail(3)
1562+
"""
1563+
out_err = mktemp() do _, f
1564+
run(`$(Base.julia_cmd()) -e "$src"`, devnull, devnull, f)
1565+
seekstart(f)
1566+
read(f, String)
1567+
end
1568+
@test !occursin("loop not unrolled", out_err)
1569+
end

0 commit comments

Comments
 (0)