thorin2
thorin2 copied to clipboard
Clos Conv FDA error
The FreeDefAna
in ClosConv
throws an error.
In Node::add_fvs
, the def is tested to be no memory.
However, this is tested in a situation that shallowly seems correct:
.con f a::[m:%mem.M, ...] = {
... // defined g
g (a#0, ...)
// ^ error occurs here
}
Reproduction
Branch: https://github.com/NeuralCoder3/thorin2/tree/ad_ptr_merge
Commit: 8a56cf0
File: lit/autodiff/imperativ/arr.thorin
Example call: ./build/bin/thorin -o - -VVVV -d autodiff -d direct -d affine lit/autodiff/imperativ/arr.thorin
Code before error:
.import affine;
.import autodiff;
.import clos;
.import compile;
.import core;
.import direct;
.import mem;
.import opt;
.import refly;
.con printInteger [%mem.M, .Idx 4294967296, .Cn %mem.M] @(<nullptr>) = {
<unset>
};
.con .extern main __2788883::[%mem.M, .Idx 4294967296, %mem.Ptr (%mem.Ptr (.Idx 256, 0), 0), return_2788887: .Cn [%mem.M, .Idx 4294967296]] @(1:(.Idx 2)) = {
.con print_integer_callback2_reshape_2788874 _2788913: %mem.M @(1:(.Idx 2)) = {
.let _2788915: %mem.M = %mem.free («100; .Idx 4294967296», 0) (_2788913, ⊥:%mem.Ptr («100; .Idx 4294967296», 0));
return_2788887 (_2788915, 0:(.Idx 4294967296))
};
.con print_integer_callback_reshape_2788818 _2788819: %mem.M @(1:(.Idx 2)) = {
.let _2788798: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100, ‹100; .Idx 4294967296›, 0) (⊥:%mem.Ptr («100; .Idx 4294967296», 0), 0:(.Idx 100));
.let _2788806: [%mem.M, .Idx 4294967296] = %mem.load (.Idx 4294967296, 0) (⊤:%mem.M, _2788798);
.let _2788855: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100, ‹100; .Idx 4294967296›, 0) (⊥:%mem.Ptr («100; .Idx 4294967296», 0), 1:(.Idx 100));
.let _2788863: [%mem.M, .Idx 4294967296] = %mem.load (.Idx 4294967296, 0) (_2788806#0:(.Idx 2), _2788855);
printInteger (_2788819, _2788863#1:(.Idx 2), %clos.attr.ret .Cn %mem.M print_integer_callback2_reshape_2788874)
};
.con init_callback_reshape_2788341 _2788374: %mem.M @(1:(.Idx 2)) = {
printInteger (_2788374, _2788806#1:(.Idx 2), %clos.attr.ret .Cn %mem.M print_integer_callback_reshape_2788818)
};
.con for_reshape_2788328 _2788998::[_2789065: %mem.M, _2789000: .Idx 4294967296] @(1:(.Idx 2)) = {
.con for_body_reshape_2788938 _2788954: %mem.M @(1:(.Idx 2)) = {
.let _2788985: [%mem.M, %mem.Ptr («100; .Idx 4294967296», 0)] = %mem.alloc («100; .Idx 4294967296», 0) _2788863#0:(.Idx 2);
.let _2789001: .Idx 100 = %core.bitcast (.Idx 100, .Idx 4294967296) _2789000;
.let _2789009: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100, ‹100; .Idx 4294967296›, 0) (_2788985#1:(.Idx 2), _2789001);
.let _2789016: %mem.M = %mem.store (.Idx 4294967296, 0) (_2788954, _2789009, _2789000);
.let _2789044: .Idx 4294967296 = %core.wrap.add 4294967296 0 (1:(.Idx 4294967296), _2789000);
for_reshape_2788328 (_2789016, _2789044)
};
.let _2789062: .Idx 2 = %core.icmp.XygLe 4294967296 (_2789000, 100:(.Idx 4294967296));
(init_callback_reshape_2788341, for_body_reshape_2788938)#_2789062 _2789065
};
for_reshape_2788328 (_2788985#0:(.Idx 2), 0:(.Idx 4294967296))
};
Error mesage:
E:dialects/clos/phase/clos_conv.h:49: memory def in free def analysis: _2788985#0:(.Idx 2) : %mem.M
E:dialects/clos/phase/clos_conv.h:50: in nom main
thorin: dialects/clos/phase/clos_conv.h:52: auto thorin::clos::FreeDefAna::Node::add_fvs(const thorin::Def*): Assertion `!match<mem::M>(def->type())' failed.
Edit: There seem to be other problems (⊥:%mem.Ptr
, ⊤:%mem.M
) that were obscured by the printing.