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

ifelse codegen produces invalid IR #50379

Closed
maleadt opened this issue Jul 1, 2023 · 0 comments · Fixed by #50528
Closed

ifelse codegen produces invalid IR #50379

maleadt opened this issue Jul 1, 2023 · 0 comments · Fixed by #50528
Assignees
Labels
compiler:codegen Generation of LLVM IR and native code kind:regression Regression in behavior compared to a previous version
Milestone

Comments

@maleadt
Copy link
Member

maleadt commented Jul 1, 2023

As seen on PkgEval.jl:

function levenberg_marquardt(OnceDifferentiable, :; maxIter, lambda, lambda_increase = 0.1, avv!)
    MAX_LAMBDA = false
    while iterCt
        if rho
            lambda = min(lambda_increase * lambda, MAX_LAMBDA)
        end
    end
end

function lmfit(f, g, p0, AbstractArray; kwargs...)
    levenberg_marquardt(R, p0; kwargs...)
end

function curve_fit(model, jacobian_model, AbstractArray, ydataAbstractArray, p0; kwargs...)
    if lmfit(f, g, p0, []; kwargs...)
    end
end

model = xdata = ydata = p0 = function jacobian_model end
curve_fit(model, jacobian_model, xdata, ydata, p0; maxIter = 1, avv! = !, lambda = 0)

Using Julia#master with assertions enabled:

Instruction does not dominate all uses!
  %58 = select i1 %ifelse_cond34, i8 %42, i8 0, !dbg !82
  %value_phi35 = phi i8 [ %58, %L24 ], [ %value_phi12, %post_union_move43 ]
Instruction does not dominate all uses!
  %55 = select i1 %ifelse_cond33, i8 %45, i8 1, !dbg !82
  %value_phi36 = phi i8 [ %55, %L24 ], [ %value_phi, %post_union_move43 ]
Instruction does not dominate all uses!
  %47 = or i1 %46, false, !dbg !79
  %53 = zext i1 %47 to i8, !dbg !82
Instruction does not dominate all uses!
  %45 = select i1 %ifelse_cond31, i8 1, i8 %value_phi27, !dbg !71
  %55 = select i1 %ifelse_cond33, i8 %45, i8 1, !dbg !82
Instruction does not dominate all uses!
  %47 = or i1 %46, false, !dbg !79
  %56 = zext i1 %47 to i8, !dbg !82
Instruction does not dominate all uses!
  %42 = select i1 %ifelse_cond30, i8 0, i8 %value_phi28, !dbg !71
  %58 = select i1 %ifelse_cond34, i8 %42, i8 0, !dbg !82
julia: /source/src/jitlayers.cpp:1223: {anonymous}::OptimizerT::operator()(llvm::orc::ThreadSafeModule, llvm::orc::MaterializationResponsibility&)::<lambda(llvm::Module&)>: Assertion `!verifyModule(M, &errs())' failed.

Bisected to #50312, so @topolarity I guess we're not out of the woods yet.

@maleadt maleadt added kind:regression Regression in behavior compared to a previous version compiler:codegen Generation of LLVM IR and native code labels Jul 1, 2023
@maleadt maleadt added this to the 1.10 milestone Jul 1, 2023
topolarity added a commit to topolarity/julia that referenced this issue Jul 12, 2023
In the presence of `attach_after` insertions, we have to be careful to
extend the basic block to include everything up to the last insertion.
We were accounting for "new" nodes (before the compaction point), but
not "pending" nodes (after the compaction point).

Fixes JuliaLang#50379.
maleadt pushed a commit that referenced this issue Jul 13, 2023
In the presence of `attach_after` insertions, we have to be careful to
extend the basic block to include everything up to the last insertion.
We were accounting for "new" nodes (before the compaction point), but
not "pending" nodes (after the compaction point).

Fixes #50379.
KristofferC pushed a commit that referenced this issue Jul 17, 2023
In the presence of `attach_after` insertions, we have to be careful to
extend the basic block to include everything up to the last insertion.
We were accounting for "new" nodes (before the compaction point), but
not "pending" nodes (after the compaction point).

Fixes #50379.

(cherry picked from commit cdec4c2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code kind:regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants