Skip to content

Commit 03f2ccf

Browse files
committed
Fixes
1 parent 2d2125d commit 03f2ccf

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/analysis/structural.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ function rewrite_ipo_return!(𝕃, compact::IncrementalCompact, line, settings,
454454
push!(eqvars.varclassification, External)
455455
push!(eqvars.varkinds, Intrinsics.Continuous)
456456

457-
new_var_ssa = insert_instruction_here!(compact, settings,
458-
NewInstruction(Expr(:invoke, nothing, variable), Incidence(nonlinrepl), Compiler.NoCallInfo(), line, Compiler.IR_FLAG_REFINED), true)
457+
new_var_ssa = insert_instruction_here!(compact, settings, @__SOURCE__,
458+
NewInstruction(Expr(:invoke, nothing, variable), Incidence(nonlinrepl), Compiler.NoCallInfo(), line, Compiler.IR_FLAG_REFINED); reverse_affinity = true)
459459

460460
eq_incidence = ultimate_rt - Incidence(nonlinrepl)
461461
push!(eqvars.total_incidence, eq_incidence)
@@ -465,13 +465,13 @@ function rewrite_ipo_return!(𝕃, compact::IncrementalCompact, line, settings,
465465
new_eq = length(eqvars.total_incidence)
466466

467467
new_eq_ssa = insert_instruction_here!(compact, settings, @__SOURCE__,
468-
NewInstruction(Expr(:invoke, nothing, equation), Eq(new_eq), Compiler.NoCallInfo(), LINE, Compiler.IR_FLAG_REFINED), true)
468+
NewInstruction(Expr(:invoke, nothing, equation), Eq(new_eq), Compiler.NoCallInfo(), line, Compiler.IR_FLAG_REFINED); reverse_affinity = true)
469469

470470
eq_val_ssa = insert_instruction_here!(compact, settings, @__SOURCE__,
471-
NewInstruction(Expr(:call, InternalIntrinsics.assign_var, new_var_ssa, ssa), eq_incidence, Compiler.NoCallInfo(), LINE, Compiler.IR_FLAG_REFINED), true)
471+
NewInstruction(Expr(:call, InternalIntrinsics.assign_var, new_var_ssa, ssa), eq_incidence, Compiler.NoCallInfo(), line, Compiler.IR_FLAG_REFINED); reverse_affinity = true)
472472

473473
eq_call_ssa = insert_instruction_here!(compact, settings, @__SOURCE__,
474-
NewInstruction(Expr(:invoke, nothing, new_eq_ssa, eq_val_ssa), Nothing, Compiler.NoCallInfo(), LINE, Compiler.IR_FLAG_REFINED), true)
474+
NewInstruction(Expr(:invoke, nothing, new_eq_ssa, eq_val_ssa), Nothing, Compiler.NoCallInfo(), line, Compiler.IR_FLAG_REFINED); reverse_affinity = true)
475475

476476
T = widenconst(ultimate_rt)
477477
# TODO: We don't have a way to express that the return value is directly this variable for arbitrary types

src/transform/tearing/schedule.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,19 @@ function find_eqs_vars(state::TransformationState)
3333
find_eqs_vars(state.structure.graph, compact)
3434
end
3535

36-
function ir_add!(compact::IncrementalCompact, line, settings::Settings, @nospecialize(_a), @nospecialize(_b), source = nothing)
36+
function ir_add!(compact::IncrementalCompact, line, settings::Settings, @nospecialize(_a), @nospecialize(_b), source = @__SOURCE__)
3737
a, b = _a, _b
3838
(b === nothing || b === 0.) && return _a
3939
(a === nothing || b === 0.) && return _b
40-
source = @something(source, @__SOURCE__)
4140
idx = insert_instruction_here!(compact, line, settings, source, :($a + $b), Any)
4241
compact[idx][:flag] |= Compiler.IR_FLAG_REFINED
4342
idx
4443
end
4544

46-
function ir_mul_const!(compact, line, settings, coeff::Float64, _a, source = nothing)
45+
function ir_mul_const!(compact, line, settings, coeff::Float64, _a, source = @__SOURCE__)
4746
if isone(coeff)
4847
return _a
4948
end
50-
source = @something(source, @__SOURCE__)
5149
idx = insert_instruction_here!(compact, line, settings, source, :($coeff * $_a), Any)
5250
compact[idx][:flag] |= Compiler.IR_FLAG_REFINED
5351
return idx
@@ -903,8 +901,8 @@ function tearing_schedule!(state::TransformationState, ci::CodeInstance, key::To
903901
push!(in_param_vars.args, argval)
904902
end
905903

906-
new_stmt.args[2] = insert_instruction_here!(compact, settinsg, NewInstruction(inst; stmt=in_param_vars, type=Tuple, flag=UInt32(0), line))
907-
sstate = insert_instruction_here!(compact, settinsg, NewInstruction(inst; stmt=new_stmt, type=Tuple, flag=UInt32(0), line))
904+
new_stmt.args[2] = insert_instruction_here!(compact, settings, @__SOURCE__, NewInstruction(inst; stmt=in_param_vars, type=Tuple, flag=UInt32(0)))
905+
sstate = insert_instruction_here!(compact, settings, @__SOURCE__, NewInstruction(inst; stmt=new_stmt, type=Tuple, flag=UInt32(0)))
908906
carried_states[sref] = CarriedSSAValue(0, sstate.id)
909907
else
910908
carried_states[sref] = isdefined(callee_sicm_ci, :rettype_const) ? callee_sicm_ci.rettype_const : callee_sicm_ci.rettype.instance
@@ -1028,7 +1026,7 @@ function tearing_schedule!(state::TransformationState, ci::CodeInstance, key::To
10281026
push!(in_vars.args, argval)
10291027
end
10301028

1031-
in_vars_ssa = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=in_vars, type=Tuple, line))
1029+
in_vars_ssa = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=in_vars, type=Tuple))
10321030

10331031
new_stmt = copy(eqinst[:stmt])
10341032
resize!(new_stmt.args, 2)
@@ -1046,17 +1044,17 @@ function tearing_schedule!(state::TransformationState, ci::CodeInstance, key::To
10461044

10471045
callee_ordinals[eq] = callee_ordinal+1
10481046

1049-
this_call = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=urs[], line))
1047+
this_call = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=urs[]))
10501048

1051-
this_eqresids = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_call, 1), type=Any, line))
1049+
this_eqresids = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_call, 1), type=Any))
10521050

1053-
new_state = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_call, 2), type=Any, line))
1051+
new_state = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_call, 2), type=Any))
10541052

10551053
carried_states[eq] = CarriedSSAValue(ordinal, new_state.id)
10561054

10571055
for (idx, this_callee_eq) in enumerate(callee_out_eqs)
10581056
this_eq = callee_eq_mapping[eq][this_callee_eq]
1059-
curval = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_eqresids, idx), type=Any, line))
1057+
curval = insert_instruction_here!(compact1, settings, @__SOURCE__, NewInstruction(eqinst; stmt=Expr(:call, getfield, this_eqresids, idx), type=Any))
10601058
push!(eqs[this_eq][2], NewSSAValue(curval.id))
10611059
end
10621060
else

src/utils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ end
146146
function insert_instruction_here!(compact::IncrementalCompact, settings::Settings, source::LineNumberNode, inst::NewInstruction; reverse_affinity::Bool = false)
147147
line = maybe_insert_debuginfo!(compact, settings, source, inst.line, compact.result_idx)
148148
inst_with_source = NewInstruction(inst.stmt, inst.type, inst.info, line, inst.flag)
149+
return insert_instruction_here!(compact, inst_with_source; reverse_affinity)
149150
end
150151

151-
function insert_instruction_here!(compact::IncrementalCompact, line, inst_ex, type; reverse_affinity::Bool = false)
152-
inst = NewInstruction(inst_ex, type, line)
152+
function insert_instruction_here!(compact::IncrementalCompact, line, stmt, @nospecialize(type); reverse_affinity::Bool = false)
153+
inst = NewInstruction(stmt, type, line)
153154
return insert_instruction_here!(compact, inst; reverse_affinity)
154155
end
155156

test/basic.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Basic
33
using Test
44
using DAECompiler
55
using DAECompiler.Intrinsics
6+
using DAECompiler: refresh
67
using Sundials
78
using SciMLBase
89
using OrdinaryDiffEq

0 commit comments

Comments
 (0)