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

Fix codegen test on debug version #46065

Merged
merged 2 commits into from
Jul 18, 2022
Merged
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
12 changes: 9 additions & 3 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ const opt_level = Base.JLOptions().opt_level
const coverage = (Base.JLOptions().code_coverage > 0) || (Base.JLOptions().malloc_log > 0)
const Iptr = sizeof(Int) == 8 ? "i64" : "i32"

const is_debug_build = ccall(:jl_is_debugbuild, Cint, ()) != 0
function libjulia_codegen_name()
is_debug_build ? "libjulia-codegen-debug" : "libjulia-codegen"
end

# `_dump_function` might be more efficient but it doesn't really matter here...
get_llvm(@nospecialize(f), @nospecialize(t), raw=true, dump_module=false, optimize=true) =
sprint(code_llvm, f, t, raw, dump_module, optimize)

if opt_level > 0
if !is_debug_build && opt_level > 0
# Make sure getptls call is removed at IR level with optimization on
@test !occursin(" call ", get_llvm(identity, Tuple{String}))
end
Expand Down Expand Up @@ -104,7 +109,7 @@ function test_jl_dump_llvm_opt()
end
end

if opt_level > 0
if !is_debug_build && opt_level > 0
# Make sure `jl_string_ptr` is inlined
@test !occursin(" call ", get_llvm(jl_string_ptr, Tuple{String}))
# Make sure `Core.sizeof` call is inlined
Expand Down Expand Up @@ -675,10 +680,11 @@ U41096 = Term41096{:U}(Modulate41096(:U, false))

@test !newexpand41096((t=t41096, μ=μ41096, U=U41096), :U)


# test that we can start julia with libjulia-codegen removed; PR #41936
mktempdir() do pfx
cp(dirname(Sys.BINDIR), pfx; force=true)
libpath = relpath(dirname(dlpath("libjulia-codegen")), dirname(Sys.BINDIR))
libpath = relpath(dirname(dlpath(libjulia_codegen_name())), dirname(Sys.BINDIR))
libs_deleted = 0
for f in filter(f -> startswith(f, "libjulia-codegen"), readdir(joinpath(pfx, libpath)))
rm(joinpath(pfx, libpath, f); force=true, recursive=true)
Expand Down