From 781ede95dc08db69e51906a8bc7c1b7c95ab4da5 Mon Sep 17 00:00:00 2001 From: Jost Berthold Date: Fri, 1 Aug 2025 16:31:04 +1000 Subject: [PATCH 1/3] Resolve array indexing projections (read local into constant index) --- kmir/src/kmir/kdist/mir-semantics/rt/data.md | 45 ++++++--- .../data/exec-smir/arrays/array_write.state | 2 +- .../exec-smir/references/array_elem_ref.rs | 20 ++++ .../references/array_elem_ref.smir.json | 1 + .../exec-smir/references/array_elem_ref.state | 92 +++++++++++++++++++ .../src/tests/integration/test_integration.py | 6 ++ 6 files changed, 153 insertions(+), 13 deletions(-) create mode 100644 kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.rs create mode 100644 kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.smir.json create mode 100644 kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.state diff --git a/kmir/src/kmir/kdist/mir-semantics/rt/data.md b/kmir/src/kmir/kdist/mir-semantics/rt/data.md index 7a00b6be2..5eed197fb 100644 --- a/kmir/src/kmir/kdist/mir-semantics/rt/data.md +++ b/kmir/src/kmir/kdist/mir-semantics/rt/data.md @@ -785,7 +785,7 @@ Other `Value`s are not expected to have pointer `Metadata` as per their types. ```k rule rvalueRef(_REGION, KIND, place(local(I), PROJS) #as PLACE) - => #mkRef(PLACE, #mutabilityOf(KIND), #metadata(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS, TYPEMAP)) + => #mkRef(PLACE, #mutabilityOf(KIND), #metadata(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS, TYPEMAP), LOCALS) ... LOCALS @@ -794,14 +794,14 @@ Other `Value`s are not expected to have pointer `Metadata` as per their types. andBool isTypedValue(LOCALS[I]) [preserves-definedness] // valid list indexing checked, #metadata should only use static information - syntax Evaluation ::= #mkRef ( Place , Mutability, Metadata) - | #mkDynSizeRef ( Place , Mutability , Evaluation ) [strict(3)] + syntax Evaluation ::= #mkRef ( Place , Mutability, Metadata, List) + | #mkDynSizeRef ( Place , Mutability , List , Evaluation ) [strict(4)] - rule #mkRef(PLACE, MUT, dynamicSize(_)) => #mkDynSizeRef(PLACE, MUT, operandCopy(PLACE)) ... - rule #mkRef(PLACE, MUT, META ) => Reference(0, PLACE, MUT, META) ... [priority(60)] + rule #mkRef( PLACE , MUT, dynamicSize(_), LOCALS) => #mkDynSizeRef(PLACE, MUT, LOCALS, operandCopy(PLACE)) ... + rule #mkRef(place(LOCAL, PROJS), MUT, META , LOCALS) => Reference(0, place(LOCAL, #resolveProjs(PROJS, LOCALS)), MUT, META) ... [priority(60)] // with dynamic metadata (reading the value) - rule #mkDynSizeRef(PLACE, MUT, VAL:Value) => Reference(0, PLACE, MUT, metadataFor(VAL)) ... + rule #mkDynSizeRef(place(LOCAL, PROJS), MUT, LOCALS, VAL:Value) => Reference(0, place(LOCAL, #resolveProjs(PROJS, LOCALS)), MUT, metadataFor(VAL)) ... syntax Metadata ::= metadataFor ( Value ) [function, total] // -------------------------------------------------------- @@ -813,6 +813,18 @@ Other `Value`s are not expected to have pointer `Metadata` as per their types. rule #mutabilityOf(borrowKindShared) => mutabilityNot rule #mutabilityOf(borrowKindFake(_)) => mutabilityNot // Shallow fake borrow disallowed in late stages rule #mutabilityOf(borrowKindMut(_)) => mutabilityMut // all mutable kinds behave equally for us + + // turns Index(LOCAL) projections into ConstantIndex(Int) + syntax ProjectionElems ::= #resolveProjs ( ProjectionElems , List ) [function, total] + // ---------------------------------------------------------------------------------- + rule #resolveProjs( .ProjectionElems , _LOCALS) => .ProjectionElems + rule #resolveProjs( projectionElemIndex(local(I)) REST, LOCALS ) => projectionElemConstantIndex(#expectUsize(getValue(LOCALS,I)), 0, false) #resolveProjs(REST, LOCALS) + requires 0 <=Int I + andBool I OTHER #resolveProjs(REST, LOCALS) [owise] ``` A `CopyForDeref` `RValue` has the semantics of a simple `Use(operandCopy(...))`, @@ -831,7 +843,7 @@ The operation typically creates a pointer with empty metadata. ```k rule rvalueAddressOf(MUT, place(local(I), PROJS) #as PLACE) => - #mkPtr(PLACE, MUT, #metadata(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS, TYPEMAP)) + #mkPtr(PLACE, MUT, #metadata(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS, TYPEMAP), LOCALS) // we should use #alignOf to emulate the address ... @@ -841,14 +853,23 @@ The operation typically creates a pointer with empty metadata. andBool isTypedValue(LOCALS[I]) [preserves-definedness] // valid list indexing checked, #metadata should only use static information - syntax Evaluation ::= #mkPtr ( Place , Mutability , Metadata ) - | #mkDynLengthPtr ( Place , Mutability, Evaluation ) [strict(3)] + syntax Evaluation ::= #mkPtr ( Place , Mutability , Metadata , List ) + | #mkDynLengthPtr ( Place , Mutability , List , Evaluation ) [strict(4)] - rule #mkPtr(PLACE, MUT, dynamicSize(_)) => #mkDynLengthPtr(PLACE, MUT, operandCopy(PLACE)) + rule #mkPtr( PLACE , MUT, dynamicSize(_), LOCALS) + => #mkDynLengthPtr(PLACE, MUT, LOCALS, operandCopy(PLACE)) + ... + - rule #mkPtr(PLACE, MUT, META) => PtrLocal(0, PLACE, MUT, ptrEmulation(META)) [priority(60)] + rule #mkPtr(place(LOCAL, PROJS), MUT, META , LOCALS) + => PtrLocal(0, place(LOCAL, #resolveProjs(PROJS, LOCALS)), MUT, ptrEmulation(META)) + ... + [priority(60)] - rule #mkDynLengthPtr(PLACE, MUT, Range(ELEMS)) => PtrLocal(0, PLACE, MUT, ptrEmulation(dynamicSize(size(ELEMS)))) + rule #mkDynLengthPtr(place(LOCAL, PROJS), MUT, LOCALS, Range(ELEMS)) + => PtrLocal(0, place(LOCAL, #resolveProjs(PROJS, LOCALS)), MUT, ptrEmulation(dynamicSize(size(ELEMS)))) + ... + ``` In practice, the `AddressOf` can often be found applied to references that get dereferenced first, diff --git a/kmir/src/tests/integration/data/exec-smir/arrays/array_write.state b/kmir/src/tests/integration/data/exec-smir/arrays/array_write.state index 0b52486da..f6ce0b4b5 100644 --- a/kmir/src/tests/integration/data/exec-smir/arrays/array_write.state +++ b/kmir/src/tests/integration/data/exec-smir/arrays/array_write.state @@ -39,7 +39,7 @@ ListItem ( typedValue ( Integer ( 0 , 64 , false ) , ty ( 25 ) , mutabilityNot ) ) ListItem ( typedValue ( Integer ( 4 , 64 , false ) , ty ( 25 ) , mutabilityMut ) ) ListItem ( typedValue ( Moved , ty ( 30 ) , mutabilityMut ) ) - ListItem ( typedValue ( Reference ( 0 , place (... local: local ( 1 ) , projection: projectionElemIndex ( local ( 6 ) ) .ProjectionElems ) , mutabilityMut , noMetadata ) , ty ( 31 ) , mutabilityNot ) ) + ListItem ( typedValue ( Reference ( 0 , place (... local: local ( 1 ) , projection: projectionElemConstantIndex (... offset: 1 , minLength: 0 , fromEnd: false ) .ProjectionElems ) , mutabilityMut , noMetadata ) , ty ( 31 ) , mutabilityNot ) ) ListItem ( typedValue ( Integer ( 1 , 64 , false ) , ty ( 25 ) , mutabilityNot ) ) ListItem ( typedValue ( Integer ( 4 , 64 , false ) , ty ( 25 ) , mutabilityMut ) ) ListItem ( typedValue ( Moved , ty ( 30 ) , mutabilityMut ) ) diff --git a/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.rs b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.rs new file mode 100644 index 000000000..6d2ee9b80 --- /dev/null +++ b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.rs @@ -0,0 +1,20 @@ +// reference into array + +fn f(x: &u32) { + assert!(*x == 0); +} + +fn g(x: *const u32) { +// assert!(unsafe{*x} == 0); // deref alignment check currently failing +} + +fn main() { + let a = [0_u32; 4]; + let i = 3; + let x = &a[i]; + let xx = x as *const u32; + + f(x); + g(xx); +} + diff --git a/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.smir.json b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.smir.json new file mode 100644 index 000000000..aaaff8504 --- /dev/null +++ b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.smir.json @@ -0,0 +1 @@ +{"name":"array_elem_ref","crate_id":9489958232688261217,"allocs":[[1,{"Memory":{"bytes":[97,115,115,101,114,116,105,111,110,32,102,97,105,108,101,100,58,32,42,120,32,61,61,32,48],"provenance":{"ptrs":[]},"align":1,"mutability":"Not"}}]],"functions":[[0,{"NormalSym":"_ZN3std2rt19lang_start_internal17h018b8394ba015d86E"}],[13,{"NormalSym":"_ZN3std3sys9backtrace28__rust_begin_short_backtrace17h1aa30458104e5addE"}],[14,{"NormalSym":"_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hbfeec03fa48def60E"}],[19,{"NormalSym":"_ZN4core3ops8function6FnOnce9call_once17h0e39fe85346befdfE"}],[20,{"IntrinsicSym":"black_box"}],[21,{"NormalSym":"_ZN4core3ops8function6FnOnce9call_once17hac80ef473907fe4aE"}],[23,{"NormalSym":"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5723dd78cefce471E"}],[25,{"NormalSym":"_ZN4core9panicking5panic17h941160ead03e2d54E"}],[32,{"NormalSym":"_ZN14array_elem_ref1f17h2d3d809fd9e95518E"}],[33,{"NormalSym":"_ZN14array_elem_ref1g17h7769fb235e84189eE"}],[41,{"NoOpSym":""}]],"uneval_consts":[],"items":[{"symbol_name":"_ZN14array_elem_ref1f17h2d3d809fd9e95518E","mono_item_kind":{"MonoItemFn":{"name":"f","id":6,"body":{"blocks":[{"statements":[{"kind":{"Assign":[{"local":2,"projection":[]},{"Use":{"Copy":{"local":1,"projection":["Deref"]}}}]},"span":51}],"terminator":{"kind":{"SwitchInt":{"discr":{"Move":{"local":2,"projection":[]}},"targets":{"branches":[[0,1]],"otherwise":2}}},"span":50}},{"statements":[],"terminator":{"kind":"Return","span":52}},{"statements":[],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":53,"user_ty":null,"const_":{"kind":"ZeroSized","ty":25,"id":9}}},"args":[{"Constant":{"span":32,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[0,0,0,0,0,0,0,0,25,0,0,0,0,0,0,0],"provenance":{"ptrs":[[0,0]]},"align":8,"mutability":"Mut"}},"ty":26,"id":10}}}],"destination":{"local":3,"projection":[]},"target":null,"unwind":"Continue"}},"span":53}}],"locals":[{"ty":1,"span":54,"mutability":"Mut"},{"ty":27,"span":55,"mutability":"Not"},{"ty":28,"span":51,"mutability":"Mut"},{"ty":29,"span":53,"mutability":"Mut"}],"arg_count":1,"var_debug_info":[{"name":"x","source_info":{"span":55,"scope":0},"composite":null,"value":{"Place":{"local":1,"projection":[]}},"argument_index":1}],"spread_arg":null,"span":56}}},"details":null},{"symbol_name":"_ZN14array_elem_ref1g17h7769fb235e84189eE","mono_item_kind":{"MonoItemFn":{"name":"g","id":7,"body":{"blocks":[{"statements":[],"terminator":{"kind":"Return","span":57}}],"locals":[{"ty":1,"span":58,"mutability":"Mut"},{"ty":30,"span":59,"mutability":"Not"}],"arg_count":1,"var_debug_info":[{"name":"x","source_info":{"span":59,"scope":0},"composite":null,"value":{"Place":{"local":1,"projection":[]}},"argument_index":1}],"spread_arg":null,"span":60}}},"details":null},{"symbol_name":"_ZN14array_elem_ref4main17h7b081d276b83a5f2E","mono_item_kind":{"MonoItemFn":{"name":"main","id":8,"body":{"blocks":[{"statements":[{"kind":{"Assign":[{"local":1,"projection":[]},{"Repeat":[{"Constant":{"span":62,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[0,0,0,0],"provenance":{"ptrs":[]},"align":4,"mutability":"Mut"}},"ty":28,"id":11}}},{"kind":{"Value":[31,{"bytes":[4,0,0,0,0,0,0,0],"provenance":{"ptrs":[]},"align":8,"mutability":"Mut"}]},"id":0}]}]},"span":63},{"kind":{"Assign":[{"local":3,"projection":[]},{"Use":{"Constant":{"span":64,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[3,0,0,0,0,0,0,0],"provenance":{"ptrs":[]},"align":8,"mutability":"Mut"}},"ty":31,"id":12}}}}]},"span":65},{"kind":{"Assign":[{"local":4,"projection":[]},{"Use":{"Constant":{"span":32,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[4,0,0,0,0,0,0,0],"provenance":{"ptrs":[]},"align":8,"mutability":"Mut"}},"ty":31,"id":13}}}}]},"span":61},{"kind":{"Assign":[{"local":5,"projection":[]},{"BinaryOp":["Lt",{"Copy":{"local":3,"projection":[]}},{"Copy":{"local":4,"projection":[]}}]}]},"span":61}],"terminator":{"kind":{"Assert":{"cond":{"Move":{"local":5,"projection":[]}},"expected":true,"msg":{"BoundsCheck":{"len":{"Move":{"local":4,"projection":[]}},"index":{"Copy":{"local":3,"projection":[]}}}},"target":1,"unwind":"Continue"}},"span":61}},{"statements":[{"kind":{"Assign":[{"local":2,"projection":[]},{"Ref":[{"kind":"ReErased"},"Shared",{"local":1,"projection":[{"Index":3}]}]}]},"span":68},{"kind":{"Assign":[{"local":6,"projection":[]},{"AddressOf":["Not",{"local":2,"projection":["Deref"]}]}]},"span":69}],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":66,"user_ty":null,"const_":{"kind":"ZeroSized","ty":32,"id":14}}},"args":[{"Copy":{"local":2,"projection":[]}}],"destination":{"local":7,"projection":[]},"target":2,"unwind":"Continue"}},"span":67}},{"statements":[],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":70,"user_ty":null,"const_":{"kind":"ZeroSized","ty":33,"id":15}}},"args":[{"Copy":{"local":6,"projection":[]}}],"destination":{"local":8,"projection":[]},"target":3,"unwind":"Continue"}},"span":71}},{"statements":[],"terminator":{"kind":"Return","span":72}}],"locals":[{"ty":1,"span":73,"mutability":"Mut"},{"ty":34,"span":74,"mutability":"Not"},{"ty":27,"span":75,"mutability":"Not"},{"ty":31,"span":65,"mutability":"Not"},{"ty":31,"span":61,"mutability":"Mut"},{"ty":35,"span":61,"mutability":"Mut"},{"ty":30,"span":76,"mutability":"Not"},{"ty":1,"span":67,"mutability":"Not"},{"ty":1,"span":71,"mutability":"Not"}],"arg_count":0,"var_debug_info":[{"name":"a","source_info":{"span":74,"scope":1},"composite":null,"value":{"Place":{"local":1,"projection":[]}},"argument_index":null},{"name":"i","source_info":{"span":77,"scope":2},"composite":null,"value":{"Const":{"span":64,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[3,0,0,0,0,0,0,0],"provenance":{"ptrs":[]},"align":8,"mutability":"Mut"}},"ty":31,"id":12}}},"argument_index":null},{"name":"x","source_info":{"span":75,"scope":3},"composite":null,"value":{"Place":{"local":2,"projection":[]}},"argument_index":null},{"name":"xx","source_info":{"span":76,"scope":4},"composite":null,"value":{"Place":{"local":6,"projection":[]}},"argument_index":null}],"spread_arg":null,"span":78}}},"details":null},{"symbol_name":"_ZN3std2rt10lang_start17h2d657fde5371ad51E","mono_item_kind":{"MonoItemFn":{"name":"std::rt::lang_start::<()>","id":0,"body":{"blocks":[{"statements":[{"kind":{"StorageLive":5},"span":1},{"kind":{"StorageLive":6},"span":2},{"kind":{"StorageLive":8},"span":3},{"kind":{"Assign":[{"local":8,"projection":[]},{"Aggregate":[{"Closure":[1,[{"Type":1},{"Type":2},{"Type":3},{"Type":4}]]},[{"Copy":{"local":1,"projection":[]}}]]}]},"span":3},{"kind":{"Assign":[{"local":7,"projection":[]},{"Ref":[{"kind":"ReErased"},"Shared",{"local":8,"projection":[]}]}]},"span":2},{"kind":{"Assign":[{"local":6,"projection":[]},{"Cast":[{"PointerCoercion":"Unsize"},{"Copy":{"local":7,"projection":[]}},5]}]},"span":2}],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":0,"user_ty":null,"const_":{"kind":"ZeroSized","ty":0,"id":0}}},"args":[{"Move":{"local":6,"projection":[]}},{"Move":{"local":2,"projection":[]}},{"Move":{"local":3,"projection":[]}},{"Move":{"local":4,"projection":[]}}],"destination":{"local":5,"projection":[]},"target":1,"unwind":"Continue"}},"span":1}},{"statements":[{"kind":{"StorageDead":6},"span":5},{"kind":{"Assign":[{"local":0,"projection":[]},{"Use":{"Copy":{"local":5,"projection":[{"Downcast":0},{"Field":[0,6]}]}}}]},"span":6},{"kind":{"StorageDead":8},"span":7},{"kind":{"StorageDead":5},"span":7}],"terminator":{"kind":"Return","span":4}}],"locals":[{"ty":6,"span":8,"mutability":"Mut"},{"ty":7,"span":9,"mutability":"Not"},{"ty":6,"span":10,"mutability":"Not"},{"ty":8,"span":11,"mutability":"Not"},{"ty":9,"span":12,"mutability":"Not"},{"ty":10,"span":1,"mutability":"Mut"},{"ty":5,"span":2,"mutability":"Mut"},{"ty":11,"span":2,"mutability":"Not"},{"ty":12,"span":3,"mutability":"Not"}],"arg_count":4,"var_debug_info":[{"name":"main","source_info":{"span":9,"scope":0},"composite":null,"value":{"Place":{"local":1,"projection":[]}},"argument_index":1},{"name":"argc","source_info":{"span":10,"scope":0},"composite":null,"value":{"Place":{"local":2,"projection":[]}},"argument_index":2},{"name":"argv","source_info":{"span":11,"scope":0},"composite":null,"value":{"Place":{"local":3,"projection":[]}},"argument_index":3},{"name":"sigpipe","source_info":{"span":12,"scope":0},"composite":null,"value":{"Place":{"local":4,"projection":[]}},"argument_index":4},{"name":"v","source_info":{"span":6,"scope":1},"composite":null,"value":{"Place":{"local":0,"projection":[]}},"argument_index":null}],"spread_arg":null,"span":13}}},"details":null},{"symbol_name":"_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5723dd78cefce471E","mono_item_kind":{"MonoItemFn":{"name":"std::rt::lang_start::<()>::{closure#0}","id":1,"body":{"blocks":[{"statements":[{"kind":{"StorageLive":2},"span":16},{"kind":{"StorageLive":3},"span":15},{"kind":{"StorageLive":4},"span":17},{"kind":{"Assign":[{"local":4,"projection":[]},{"Use":{"Copy":{"local":1,"projection":["Deref",{"Field":[0,7]}]}}}]},"span":17}],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":14,"user_ty":null,"const_":{"kind":"ZeroSized","ty":13,"id":1}}},"args":[{"Move":{"local":4,"projection":[]}}],"destination":{"local":3,"projection":[]},"target":1,"unwind":"Continue"}},"span":15}},{"statements":[{"kind":{"StorageDead":4},"span":19}],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":18,"user_ty":null,"const_":{"kind":"ZeroSized","ty":14,"id":2}}},"args":[{"Move":{"local":3,"projection":[]}}],"destination":{"local":2,"projection":[]},"target":2,"unwind":"Continue"}},"span":16}},{"statements":[{"kind":{"StorageDead":3},"span":21},{"kind":{"StorageLive":5},"span":22},{"kind":{"Assign":[{"local":5,"projection":[]},{"Ref":[{"kind":"ReErased"},"Shared",{"local":2,"projection":[{"Field":[0,15]}]}]}]},"span":22},{"kind":{"StorageLive":6},"span":23},{"kind":{"Assign":[{"local":6,"projection":[]},{"Use":{"Copy":{"local":2,"projection":[{"Field":[0,15]},{"Field":[0,9]}]}}}]},"span":23},{"kind":{"Assign":[{"local":0,"projection":[]},{"Cast":["IntToInt",{"Move":{"local":6,"projection":[]}},16]}]},"span":24},{"kind":{"StorageDead":6},"span":25},{"kind":{"StorageDead":5},"span":26},{"kind":{"StorageDead":2},"span":27}],"terminator":{"kind":"Return","span":20}}],"locals":[{"ty":16,"span":28,"mutability":"Mut"},{"ty":11,"span":3,"mutability":"Mut"},{"ty":17,"span":16,"mutability":"Mut"},{"ty":1,"span":15,"mutability":"Mut"},{"ty":7,"span":17,"mutability":"Mut"},{"ty":18,"span":22,"mutability":"Mut"},{"ty":9,"span":23,"mutability":"Mut"}],"arg_count":1,"var_debug_info":[{"name":"main","source_info":{"span":9,"scope":0},"composite":null,"value":{"Place":{"local":1,"projection":["Deref",{"Field":[0,7]}]}},"argument_index":null},{"name":"self","source_info":{"span":29,"scope":1},"composite":null,"value":{"Place":{"local":2,"projection":[]}},"argument_index":1},{"name":"self","source_info":{"span":30,"scope":2},"composite":null,"value":{"Place":{"local":5,"projection":[]}},"argument_index":1}],"spread_arg":null,"span":3}}},"details":null},{"symbol_name":"_ZN3std3sys9backtrace28__rust_begin_short_backtrace17h1aa30458104e5addE","mono_item_kind":{"MonoItemFn":{"name":"std::sys::backtrace::__rust_begin_short_backtrace::","id":2,"body":{"blocks":[{"statements":[],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":31,"user_ty":null,"const_":{"kind":"ZeroSized","ty":19,"id":3}}},"args":[{"Move":{"local":1,"projection":[]}},{"Constant":{"span":32,"user_ty":null,"const_":{"kind":"ZeroSized","ty":1,"id":4}}}],"destination":{"local":0,"projection":[]},"target":1,"unwind":"Continue"}},"span":33}},{"statements":[],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":34,"user_ty":null,"const_":{"kind":"ZeroSized","ty":20,"id":5}}},"args":[{"Constant":{"span":32,"user_ty":null,"const_":{"kind":"ZeroSized","ty":1,"id":4}}}],"destination":{"local":2,"projection":[]},"target":2,"unwind":"Unreachable"}},"span":35}},{"statements":[],"terminator":{"kind":"Return","span":36}}],"locals":[{"ty":1,"span":37,"mutability":"Mut"},{"ty":7,"span":38,"mutability":"Not"},{"ty":1,"span":39,"mutability":"Not"}],"arg_count":1,"var_debug_info":[{"name":"f","source_info":{"span":38,"scope":0},"composite":null,"value":{"Place":{"local":1,"projection":[]}},"argument_index":1},{"name":"result","source_info":{"span":40,"scope":1},"composite":null,"value":{"Place":{"local":0,"projection":[]}},"argument_index":null},{"name":"dummy","source_info":{"span":41,"scope":2},"composite":null,"value":{"Const":{"span":32,"user_ty":null,"const_":{"kind":"ZeroSized","ty":1,"id":4}}},"argument_index":1}],"spread_arg":null,"span":42}}},"details":null},{"symbol_name":"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h70b539ed5af83defE","mono_item_kind":{"MonoItemFn":{"name":"<{closure@std::rt::lang_start<()>::{closure#0}} as std::ops::FnOnce<()>>::call_once","id":3,"body":{"blocks":[{"statements":[],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":43,"user_ty":null,"const_":{"kind":"ZeroSized","ty":21,"id":6}}},"args":[{"Move":{"local":1,"projection":["Deref"]}},{"Move":{"local":2,"projection":[]}}],"destination":{"local":0,"projection":[]},"target":1,"unwind":"Continue"}},"span":43}},{"statements":[],"terminator":{"kind":"Return","span":43}}],"locals":[{"ty":16,"span":43,"mutability":"Mut"},{"ty":22,"span":43,"mutability":"Not"},{"ty":1,"span":43,"mutability":"Not"}],"arg_count":2,"var_debug_info":[],"spread_arg":2,"span":43}}},"details":null},{"symbol_name":"_ZN4core3ops8function6FnOnce9call_once17h0e39fe85346befdfE","mono_item_kind":{"MonoItemFn":{"name":">::call_once","id":3,"body":{"blocks":[{"statements":[],"terminator":{"kind":{"Call":{"func":{"Move":{"local":1,"projection":[]}},"args":[],"destination":{"local":0,"projection":[]},"target":1,"unwind":"Continue"}},"span":43}},{"statements":[],"terminator":{"kind":"Return","span":43}}],"locals":[{"ty":1,"span":43,"mutability":"Mut"},{"ty":7,"span":43,"mutability":"Not"},{"ty":1,"span":43,"mutability":"Not"}],"arg_count":2,"var_debug_info":[],"spread_arg":2,"span":43}}},"details":null},{"symbol_name":"_ZN4core3ops8function6FnOnce9call_once17hac80ef473907fe4aE","mono_item_kind":{"MonoItemFn":{"name":"<{closure@std::rt::lang_start<()>::{closure#0}} as std::ops::FnOnce<()>>::call_once","id":3,"body":{"blocks":[{"statements":[{"kind":{"Assign":[{"local":3,"projection":[]},{"Ref":[{"kind":"ReErased"},{"Mut":{"kind":"Default"}},{"local":1,"projection":[]}]}]},"span":43}],"terminator":{"kind":{"Call":{"func":{"Constant":{"span":43,"user_ty":null,"const_":{"kind":"ZeroSized","ty":23,"id":7}}},"args":[{"Move":{"local":3,"projection":[]}},{"Move":{"local":2,"projection":[]}}],"destination":{"local":0,"projection":[]},"target":1,"unwind":{"Cleanup":3}}},"span":43}},{"statements":[],"terminator":{"kind":{"Drop":{"place":{"local":1,"projection":[]},"target":2,"unwind":"Continue"}},"span":43}},{"statements":[],"terminator":{"kind":"Return","span":43}},{"statements":[],"terminator":{"kind":{"Drop":{"place":{"local":1,"projection":[]},"target":4,"unwind":"Terminate"}},"span":43}},{"statements":[],"terminator":{"kind":"Resume","span":43}}],"locals":[{"ty":16,"span":43,"mutability":"Mut"},{"ty":12,"span":43,"mutability":"Not"},{"ty":1,"span":43,"mutability":"Not"},{"ty":24,"span":43,"mutability":"Not"}],"arg_count":2,"var_debug_info":[],"spread_arg":2,"span":43}}},"details":null},{"symbol_name":"_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h0aceace11b9d3557E","mono_item_kind":{"MonoItemFn":{"name":"std::ptr::drop_in_place::<{closure@std::rt::lang_start<()>::{closure#0}}>","id":4,"body":{"blocks":[{"statements":[],"terminator":{"kind":"Return","span":44}}],"locals":[{"ty":1,"span":44,"mutability":"Mut"},{"ty":22,"span":44,"mutability":"Not"}],"arg_count":1,"var_debug_info":[],"spread_arg":null,"span":44}}},"details":null},{"symbol_name":"_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hbfeec03fa48def60E","mono_item_kind":{"MonoItemFn":{"name":"<() as std::process::Termination>::report","id":5,"body":{"blocks":[{"statements":[{"kind":{"Assign":[{"local":0,"projection":[]},{"Use":{"Constant":{"span":46,"user_ty":null,"const_":{"kind":{"Allocated":{"bytes":[0],"provenance":{"ptrs":[]},"align":1,"mutability":"Mut"}},"ty":17,"id":8}}}}]},"span":46}],"terminator":{"kind":"Return","span":45}}],"locals":[{"ty":17,"span":47,"mutability":"Mut"},{"ty":1,"span":48,"mutability":"Not"}],"arg_count":1,"var_debug_info":[{"name":"self","source_info":{"span":48,"scope":0},"composite":null,"value":{"Const":{"span":32,"user_ty":null,"const_":{"kind":"ZeroSized","ty":1,"id":4}}},"argument_index":1}],"spread_arg":null,"span":49}}},"details":null}],"types":[[1,{"TupleType":{"types":[],"layout":{"fields":{"Arbitrary":{"offsets":[]}},"variants":{"Single":{"index":0}},"abi":{"Aggregate":{"sized":true}},"abi_align":1,"size":{"num_bits":0}}}}],[5,{"RefType":{"pointee_type":39,"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0},{"num_bits":64}]}},"variants":{"Single":{"index":0}},"abi":{"ScalarPair":[{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}},{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}]},"abi_align":8,"size":{"num_bits":128}}}}],[6,{"PrimitiveType":{"Int":"Isize"}}],[8,{"PtrType":{"pointee_type":40,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":0,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[9,{"PrimitiveType":{"Uint":"U8"}}],[10,{"EnumType":{"name":"std::result::Result","adt_def":24,"discriminants":[0,1],"fields":[[6],[29]],"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0}]}},"variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Int":{"length":"I64","signed":true}},"valid_range":{"start":0,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[11,{"RefType":{"pointee_type":12,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[15,{"StructType":{"name":"std::sys::pal::unix::process::process_common::ExitCode","adt_def":12,"fields":[9],"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0}]}},"variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Int":{"length":"I8","signed":false}},"valid_range":{"start":0,"end":255}}}},"abi_align":1,"size":{"num_bits":8}}}}],[16,{"PrimitiveType":{"Int":"I32"}}],[17,{"StructType":{"name":"std::process::ExitCode","adt_def":10,"fields":[15],"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0}]}},"variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Int":{"length":"I8","signed":false}},"valid_range":{"start":0,"end":255}}}},"abi_align":1,"size":{"num_bits":8}}}}],[18,{"RefType":{"pointee_type":15,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[22,{"PtrType":{"pointee_type":12,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":0,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[24,{"RefType":{"pointee_type":12,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[26,{"RefType":{"pointee_type":37,"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0},{"num_bits":64}]}},"variants":{"Single":{"index":0}},"abi":{"ScalarPair":[{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}},{"Initialized":{"value":{"Int":{"length":"I64","signed":false}},"valid_range":{"start":0,"end":18446744073709551615}}}]},"abi_align":8,"size":{"num_bits":128}}}}],[27,{"RefType":{"pointee_type":28,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[28,{"PrimitiveType":{"Uint":"U32"}}],[29,"VoidType"],[30,{"PtrType":{"pointee_type":28,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":0,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[31,{"PrimitiveType":{"Uint":"Usize"}}],[34,{"ArrayType":{"elem_type":28,"size":{"kind":{"Value":[31,{"bytes":[4,0,0,0,0,0,0,0],"provenance":{"ptrs":[]},"align":8,"mutability":"Mut"}]},"id":0},"layout":{"fields":{"Array":{"stride":{"num_bits":32},"count":4}},"variants":{"Single":{"index":0}},"abi":{"Aggregate":{"sized":true}},"abi_align":4,"size":{"num_bits":128}}}}],[35,{"PrimitiveType":"Bool"}],[36,{"RefType":{"pointee_type":38,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":1,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}],[37,{"PrimitiveType":"Str"}],[38,{"StructType":{"name":"std::panic::Location<'_>","adt_def":15,"fields":[26,28,28],"layout":{"fields":{"Arbitrary":{"offsets":[{"num_bits":0},{"num_bits":128},{"num_bits":160}]}},"variants":{"Single":{"index":0}},"abi":{"Aggregate":{"sized":true}},"abi_align":8,"size":{"num_bits":192}}}}],[40,{"PtrType":{"pointee_type":9,"layout":{"fields":"Primitive","variants":{"Single":{"index":0}},"abi":{"Scalar":{"Initialized":{"value":{"Pointer":0},"valid_range":{"start":0,"end":18446744073709551615}}}},"abi_align":8,"size":{"num_bits":64}}}}]],"spans":[[0,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",194,17,194,36]],[1,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",194,17,199,6]],[2,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,9,195,93]],[3,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,10,195,93]],[4,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",201,2,201,2]],[5,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",199,5,199,6]],[6,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",194,12,194,13]],[7,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",199,6,199,7]],[9,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",189,5,189,9]],[10,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",190,5,190,9]],[11,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",191,5,191,9]],[12,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",192,5,192,12]],[13,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",188,1,201,2]],[14,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,18,195,69]],[15,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,18,195,75]],[16,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,18,195,84]],[17,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,70,195,74]],[18,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,76,195,82]],[19,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,74,195,75]],[20,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,93,195,93]],[21,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,83,195,84]],[22,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2053,9,2053,15]],[23,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_common.rs",636,9,636,15]],[24,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_common.rs",636,9,636,22]],[25,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_common.rs",636,21,636,22]],[26,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2053,23,2053,24]],[27,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs",195,92,195,93]],[29,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2052,19,2052,23]],[30,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_common.rs",635,19,635,24]],[31,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",154,18,154,19]],[32,["no-location",0,0,0,0]],[33,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",154,18,154,21]],[34,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/hint.rs",389,5,389,33]],[35,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/hint.rs",389,5,389,40]],[36,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",160,2,160,2]],[38,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",150,43,150,44]],[40,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",154,9,154,15]],[41,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/hint.rs",388,27,388,32]],[42,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",150,1,160,2]],[43,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs",250,5,250,71]],[44,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs",521,1,521,56]],[45,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2424,6,2424,6]],[46,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2423,9,2423,26]],[48,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2422,15,2422,19]],[49,["/home/jost/.rustup/toolchains/nightly-2024-11-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs",2422,5,2424,6]],[50,["array_elem_ref.rs",4,11,4,18]],[51,["array_elem_ref.rs",4,11,4,13]],[52,["array_elem_ref.rs",5,2,5,2]],[53,["array_elem_ref.rs",4,3,4,19]],[55,["array_elem_ref.rs",3,6,3,7]],[56,["array_elem_ref.rs",3,1,5,2]],[57,["array_elem_ref.rs",9,2,9,2]],[59,["array_elem_ref.rs",7,6,7,7]],[60,["array_elem_ref.rs",7,1,9,2]],[61,["array_elem_ref.rs",14,12,14,16]],[62,["array_elem_ref.rs",12,12,12,17]],[63,["array_elem_ref.rs",12,11,12,21]],[64,["array_elem_ref.rs",13,11,13,12]],[65,["array_elem_ref.rs",14,14,14,15]],[66,["array_elem_ref.rs",17,3,17,4]],[67,["array_elem_ref.rs",17,3,17,7]],[68,["array_elem_ref.rs",14,11,14,16]],[69,["array_elem_ref.rs",15,12,15,13]],[70,["array_elem_ref.rs",18,3,18,4]],[71,["array_elem_ref.rs",18,3,18,8]],[72,["array_elem_ref.rs",19,2,19,2]],[74,["array_elem_ref.rs",12,7,12,8]],[75,["array_elem_ref.rs",14,7,14,8]],[76,["array_elem_ref.rs",15,7,15,9]],[77,["array_elem_ref.rs",13,7,13,8]],[78,["array_elem_ref.rs",11,1,19,2]]],"debug":null,"machine":{"endian":"Little","pointer_width":{"num_bits":64}}} \ No newline at end of file diff --git a/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.state b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.state new file mode 100644 index 000000000..7f1ebbe6c --- /dev/null +++ b/kmir/src/tests/integration/data/exec-smir/references/array_elem_ref.state @@ -0,0 +1,92 @@ + + + #EndProgram ~> .K + + + noReturn + + + ty ( -1 ) + + + + ListItem ( basicBlock (... statements: statement (... kind: statementKindAssign (... place: place (... local: local ( 1 ) , projection: .ProjectionElems ) , rvalue: rvalueRepeat ( operandConstant ( constOperand (... span: span ( 62 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 4 ) , mutability: mutabilityMut ) ) , ty: ty ( 28 ) , id: mirConstId ( 11 ) ) ) ) , tyConst (... kind: tyConstKindValue ( ty ( 31 ) , allocation (... bytes: b"\x04\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , id: tyConstId ( 0 ) ) ) ) , span: span ( 63 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 3 ) , projection: .ProjectionElems ) , rvalue: rvalueUse ( operandConstant ( constOperand (... span: span ( 64 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x03\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 31 ) , id: mirConstId ( 12 ) ) ) ) ) ) , span: span ( 65 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 4 ) , projection: .ProjectionElems ) , rvalue: rvalueUse ( operandConstant ( constOperand (... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x04\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 31 ) , id: mirConstId ( 13 ) ) ) ) ) ) , span: span ( 61 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 5 ) , projection: .ProjectionElems ) , rvalue: rvalueBinaryOp ( binOpLt , operandCopy ( place (... local: local ( 3 ) , projection: .ProjectionElems ) ) , operandCopy ( place (... local: local ( 4 ) , projection: .ProjectionElems ) ) ) ) , span: span ( 61 ) ) .Statements , terminator: terminator (... kind: assert (... cond: operandMove ( place (... local: local ( 5 ) , projection: .ProjectionElems ) ) , expected: true , msg: assertMessageBoundsCheck (... len: operandMove ( place (... local: local ( 4 ) , projection: .ProjectionElems ) ) , index: operandCopy ( place (... local: local ( 3 ) , projection: .ProjectionElems ) ) ) , target: basicBlockIdx ( 1 ) , unwind: unwindActionContinue ) , span: span ( 61 ) ) ) ) + ListItem ( basicBlock (... statements: statement (... kind: statementKindAssign (... place: place (... local: local ( 2 ) , projection: .ProjectionElems ) , rvalue: rvalueRef ( region (... kind: regionKindReErased ) , borrowKindShared , place (... local: local ( 1 ) , projection: projectionElemIndex ( local ( 3 ) ) .ProjectionElems ) ) ) , span: span ( 68 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 6 ) , projection: .ProjectionElems ) , rvalue: rvalueAddressOf ( mutabilityNot , place (... local: local ( 2 ) , projection: projectionElemDeref .ProjectionElems ) ) ) , span: span ( 69 ) ) .Statements , terminator: terminator (... kind: terminatorKindCall (... func: operandConstant ( constOperand (... span: span ( 66 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindZeroSized , ty: ty ( 32 ) , id: mirConstId ( 14 ) ) ) ) , args: operandCopy ( place (... local: local ( 2 ) , projection: .ProjectionElems ) ) .Operands , destination: place (... local: local ( 7 ) , projection: .ProjectionElems ) , target: someBasicBlockIdx ( basicBlockIdx ( 2 ) ) , unwind: unwindActionContinue ) , span: span ( 67 ) ) ) ) + ListItem ( basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindCall (... func: operandConstant ( constOperand (... span: span ( 70 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindZeroSized , ty: ty ( 33 ) , id: mirConstId ( 15 ) ) ) ) , args: operandCopy ( place (... local: local ( 6 ) , projection: .ProjectionElems ) ) .Operands , destination: place (... local: local ( 8 ) , projection: .ProjectionElems ) , target: someBasicBlockIdx ( basicBlockIdx ( 3 ) ) , unwind: unwindActionContinue ) , span: span ( 71 ) ) ) ) + ListItem ( basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindReturn , span: span ( 72 ) ) ) ) + + + ty ( -1 ) + + + place (... local: local ( 0 ) , projection: .ProjectionElems ) + + + noBasicBlockIdx + + + unwindActionContinue + + + ListItem ( newLocal ( ty ( 1 ) , mutabilityMut ) ) + ListItem ( typedValue ( Range ( ListItem ( Integer ( 0 , 32 , false ) ) + ListItem ( Integer ( 0 , 32 , false ) ) + ListItem ( Integer ( 0 , 32 , false ) ) + ListItem ( Integer ( 0 , 32 , false ) ) ) , ty ( 34 ) , mutabilityNot ) ) + ListItem ( typedValue ( Reference ( 0 , place (... local: local ( 1 ) , projection: projectionElemConstantIndex (... offset: 3 , minLength: 0 , fromEnd: false ) .ProjectionElems ) , mutabilityNot , noMetadata ) , ty ( 27 ) , mutabilityNot ) ) + ListItem ( typedValue ( Integer ( 3 , 64 , false ) , ty ( 31 ) , mutabilityNot ) ) + ListItem ( typedValue ( Integer ( 4 , 64 , false ) , ty ( 31 ) , mutabilityMut ) ) + ListItem ( typedValue ( Moved , ty ( 35 ) , mutabilityMut ) ) + ListItem ( typedValue ( PtrLocal ( 0 , place (... local: local ( 1 ) , projection: projectionElemConstantIndex (... offset: 3 , minLength: 0 , fromEnd: false ) .ProjectionElems ) , mutabilityNot , ptrEmulation ( noMetadata ) ) , ty ( 30 ) , mutabilityNot ) ) + ListItem ( newLocal ( ty ( 1 ) , mutabilityNot ) ) + ListItem ( newLocal ( ty ( 1 ) , mutabilityNot ) ) + + + + ListItem ( StackFrame ( ty ( -1 ) , place (... local: local ( -1 ) , projection: .ProjectionElems ) , noBasicBlockIdx , unwindActionUnreachable , .List ) ) + + + .Map + + + ty ( 32 ) |-> monoItemFn (... name: symbol ( "f" ) , id: defId ( 6 ) , body: someBody ( body (... blocks: basicBlock (... statements: statement (... kind: statementKindAssign (... place: place (... local: local ( 2 ) , projection: .ProjectionElems ) , rvalue: rvalueUse ( operandCopy ( place (... local: local ( 1 ) , projection: projectionElemDeref .ProjectionElems ) ) ) ) , span: span ( 51 ) ) .Statements , terminator: terminator (... kind: terminatorKindSwitchInt (... discr: operandMove ( place (... local: local ( 2 ) , projection: .ProjectionElems ) ) , targets: switchTargets (... branches: branch ( 0 , basicBlockIdx ( 1 ) ) .Branches , otherwise: basicBlockIdx ( 2 ) ) ) , span: span ( 50 ) ) ) basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindReturn , span: span ( 52 ) ) ) basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindCall (... func: operandConstant ( constOperand (... span: span ( 53 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindZeroSized , ty: ty ( 25 ) , id: mirConstId ( 9 ) ) ) ) , args: operandConstant ( constOperand (... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: provenanceMapEntry (... provSize: 0 , allocId: allocId ( 0 ) ) .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 26 ) , id: mirConstId ( 10 ) ) ) ) .Operands , destination: place (... local: local ( 3 ) , projection: .ProjectionElems ) , target: noBasicBlockIdx , unwind: unwindActionContinue ) , span: span ( 53 ) ) ) .BasicBlocks , locals: localDecl (... ty: ty ( 1 ) , span: span ( 54 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 27 ) , span: span ( 55 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 28 ) , span: span ( 51 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 29 ) , span: span ( 53 ) , mut: mutabilityMut ) .LocalDecls , argCount: 1 , varDebugInfo: varDebugInfo (... name: symbol ( "x" ) , sourceInfo: sourceInfo (... span: span ( 55 ) , scope: sourceScope ( 0 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsPlace ( place (... local: local ( 1 ) , projection: .ProjectionElems ) ) , argumentIndex: someInt ( 1 ) ) .VarDebugInfos , spreadArg: noLocal , span: span ( 56 ) ) ) ) + ty ( 33 ) |-> monoItemFn (... name: symbol ( "g" ) , id: defId ( 7 ) , body: someBody ( body (... blocks: basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindReturn , span: span ( 57 ) ) ) .BasicBlocks , locals: localDecl (... ty: ty ( 1 ) , span: span ( 58 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 30 ) , span: span ( 59 ) , mut: mutabilityNot ) .LocalDecls , argCount: 1 , varDebugInfo: varDebugInfo (... name: symbol ( "x" ) , sourceInfo: sourceInfo (... span: span ( 59 ) , scope: sourceScope ( 0 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsPlace ( place (... local: local ( 1 ) , projection: .ProjectionElems ) ) , argumentIndex: someInt ( 1 ) ) .VarDebugInfos , spreadArg: noLocal , span: span ( 60 ) ) ) ) + ty ( -1 ) |-> monoItemFn (... name: symbol ( "main" ) , id: defId ( 8 ) , body: someBody ( body (... blocks: basicBlock (... statements: statement (... kind: statementKindAssign (... place: place (... local: local ( 1 ) , projection: .ProjectionElems ) , rvalue: rvalueRepeat ( operandConstant ( constOperand (... span: span ( 62 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 4 ) , mutability: mutabilityMut ) ) , ty: ty ( 28 ) , id: mirConstId ( 11 ) ) ) ) , tyConst (... kind: tyConstKindValue ( ty ( 31 ) , allocation (... bytes: b"\x04\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , id: tyConstId ( 0 ) ) ) ) , span: span ( 63 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 3 ) , projection: .ProjectionElems ) , rvalue: rvalueUse ( operandConstant ( constOperand (... span: span ( 64 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x03\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 31 ) , id: mirConstId ( 12 ) ) ) ) ) ) , span: span ( 65 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 4 ) , projection: .ProjectionElems ) , rvalue: rvalueUse ( operandConstant ( constOperand (... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x04\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 31 ) , id: mirConstId ( 13 ) ) ) ) ) ) , span: span ( 61 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 5 ) , projection: .ProjectionElems ) , rvalue: rvalueBinaryOp ( binOpLt , operandCopy ( place (... local: local ( 3 ) , projection: .ProjectionElems ) ) , operandCopy ( place (... local: local ( 4 ) , projection: .ProjectionElems ) ) ) ) , span: span ( 61 ) ) .Statements , terminator: terminator (... kind: assert (... cond: operandMove ( place (... local: local ( 5 ) , projection: .ProjectionElems ) ) , expected: true , msg: assertMessageBoundsCheck (... len: operandMove ( place (... local: local ( 4 ) , projection: .ProjectionElems ) ) , index: operandCopy ( place (... local: local ( 3 ) , projection: .ProjectionElems ) ) ) , target: basicBlockIdx ( 1 ) , unwind: unwindActionContinue ) , span: span ( 61 ) ) ) basicBlock (... statements: statement (... kind: statementKindAssign (... place: place (... local: local ( 2 ) , projection: .ProjectionElems ) , rvalue: rvalueRef ( region (... kind: regionKindReErased ) , borrowKindShared , place (... local: local ( 1 ) , projection: projectionElemIndex ( local ( 3 ) ) .ProjectionElems ) ) ) , span: span ( 68 ) ) statement (... kind: statementKindAssign (... place: place (... local: local ( 6 ) , projection: .ProjectionElems ) , rvalue: rvalueAddressOf ( mutabilityNot , place (... local: local ( 2 ) , projection: projectionElemDeref .ProjectionElems ) ) ) , span: span ( 69 ) ) .Statements , terminator: terminator (... kind: terminatorKindCall (... func: operandConstant ( constOperand (... span: span ( 66 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindZeroSized , ty: ty ( 32 ) , id: mirConstId ( 14 ) ) ) ) , args: operandCopy ( place (... local: local ( 2 ) , projection: .ProjectionElems ) ) .Operands , destination: place (... local: local ( 7 ) , projection: .ProjectionElems ) , target: someBasicBlockIdx ( basicBlockIdx ( 2 ) ) , unwind: unwindActionContinue ) , span: span ( 67 ) ) ) basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindCall (... func: operandConstant ( constOperand (... span: span ( 70 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindZeroSized , ty: ty ( 33 ) , id: mirConstId ( 15 ) ) ) ) , args: operandCopy ( place (... local: local ( 6 ) , projection: .ProjectionElems ) ) .Operands , destination: place (... local: local ( 8 ) , projection: .ProjectionElems ) , target: someBasicBlockIdx ( basicBlockIdx ( 3 ) ) , unwind: unwindActionContinue ) , span: span ( 71 ) ) ) basicBlock (... statements: .Statements , terminator: terminator (... kind: terminatorKindReturn , span: span ( 72 ) ) ) .BasicBlocks , locals: localDecl (... ty: ty ( 1 ) , span: span ( 73 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 34 ) , span: span ( 74 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 27 ) , span: span ( 75 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 31 ) , span: span ( 65 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 31 ) , span: span ( 61 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 35 ) , span: span ( 61 ) , mut: mutabilityMut ) localDecl (... ty: ty ( 30 ) , span: span ( 76 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 1 ) , span: span ( 67 ) , mut: mutabilityNot ) localDecl (... ty: ty ( 1 ) , span: span ( 71 ) , mut: mutabilityNot ) .LocalDecls , argCount: 0 , varDebugInfo: varDebugInfo (... name: symbol ( "a" ) , sourceInfo: sourceInfo (... span: span ( 74 ) , scope: sourceScope ( 1 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsPlace ( place (... local: local ( 1 ) , projection: .ProjectionElems ) ) , argumentIndex: noInt ) varDebugInfo (... name: symbol ( "i" ) , sourceInfo: sourceInfo (... span: span ( 77 ) , scope: sourceScope ( 2 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsConst ( constOperand (... span: span ( 64 ) , userTy: noUserTypeAnnotationIndex , const: mirConst (... kind: constantKindAllocated ( allocation (... bytes: b"\x03\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 31 ) , id: mirConstId ( 12 ) ) ) ) , argumentIndex: noInt ) varDebugInfo (... name: symbol ( "x" ) , sourceInfo: sourceInfo (... span: span ( 75 ) , scope: sourceScope ( 3 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsPlace ( place (... local: local ( 2 ) , projection: .ProjectionElems ) ) , argumentIndex: noInt ) varDebugInfo (... name: symbol ( "xx" ) , sourceInfo: sourceInfo (... span: span ( 76 ) , scope: sourceScope ( 4 ) ) , composite: noVarDebugInfoFragment , value: varDebugInfoContentsPlace ( place (... local: local ( 6 ) , projection: .ProjectionElems ) ) , argumentIndex: noInt ) .VarDebugInfos , spreadArg: noLocal , span: span ( 78 ) ) ) ) + + + symbol ( "main" ) + + + ty ( 1 ) |-> typeInfoTupleType ( .Tys ) + ty ( 5 ) |-> typeInfoRefType ( ty ( 39 ) ) + ty ( 6 ) |-> typeInfoPrimitiveType ( primTypeInt ( intTyIsize ) ) + ty ( 8 ) |-> typeInfoPtrType ( ty ( 40 ) ) + ty ( 9 ) |-> typeInfoPrimitiveType ( primTypeUint ( uintTyU8 ) ) + ty ( 10 ) |-> typeInfoEnumType ( "std::result::Result" , adtDef ( 24 ) , Discriminant ( 0 ) Discriminant ( 1 ) .Discriminants ) + ty ( 11 ) |-> typeInfoRefType ( ty ( 12 ) ) + ty ( 15 ) |-> typeInfoStructType ( "std::sys::pal::unix::process::process_common::ExitCode" , adtDef ( 12 ) , ty ( 9 ) .Tys ) + ty ( 16 ) |-> typeInfoPrimitiveType ( primTypeInt ( intTyI32 ) ) + ty ( 17 ) |-> typeInfoStructType ( "std::process::ExitCode" , adtDef ( 10 ) , ty ( 15 ) .Tys ) + ty ( 18 ) |-> typeInfoRefType ( ty ( 15 ) ) + ty ( 22 ) |-> typeInfoPtrType ( ty ( 12 ) ) + ty ( 24 ) |-> typeInfoRefType ( ty ( 12 ) ) + ty ( 26 ) |-> typeInfoRefType ( ty ( 37 ) ) + ty ( 27 ) |-> typeInfoRefType ( ty ( 28 ) ) + ty ( 28 ) |-> typeInfoPrimitiveType ( primTypeUint ( uintTyU32 ) ) + ty ( 29 ) |-> typeInfoVoidType + ty ( 30 ) |-> typeInfoPtrType ( ty ( 28 ) ) + ty ( 31 ) |-> typeInfoPrimitiveType ( primTypeUint ( uintTyUsize ) ) + ty ( 34 ) |-> typeInfoArrayType ( ty ( 28 ) , someTyConst ( tyConst (... kind: tyConstKindValue ( ty ( 31 ) , allocation (... bytes: b"\x04\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap (... ptrs: .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , id: tyConstId ( 0 ) ) ) ) + ty ( 35 ) |-> typeInfoPrimitiveType ( primTypeBool ) + ty ( 36 ) |-> typeInfoRefType ( ty ( 38 ) ) + ty ( 37 ) |-> typeInfoPrimitiveType ( primTypeStr ) + ty ( 38 ) |-> typeInfoStructType ( "std::panic::Location<'_>" , adtDef ( 15 ) , ty ( 26 ) ty ( 28 ) ty ( 28 ) .Tys ) + ty ( 40 ) |-> typeInfoPtrType ( ty ( 9 ) ) + + + adtDef ( 10 ) |-> ty ( 17 ) + adtDef ( 12 ) |-> ty ( 15 ) + adtDef ( 15 ) |-> ty ( 38 ) + adtDef ( 24 ) |-> ty ( 10 ) + + \ No newline at end of file diff --git a/kmir/src/tests/integration/test_integration.py b/kmir/src/tests/integration/test_integration.py index c831842bf..9622978af 100644 --- a/kmir/src/tests/integration/test_integration.py +++ b/kmir/src/tests/integration/test_integration.py @@ -276,6 +276,12 @@ def test_crate_examples(main_crate: Path, kmir: KMIR, update_expected_output: bo EXEC_DATA_DIR / 'pointers' / 'pointer-cast-length-test-fail.state', 1000, ), + ( + 'Ref-array-elem-ref', + EXEC_DATA_DIR / 'references' / 'array_elem_ref.smir.json', + EXEC_DATA_DIR / 'references' / 'array_elem_ref.state', + None, + ), ] From 0b1869583765c65ecc7c6221e7092c5418370dd6 Mon Sep 17 00:00:00 2001 From: Jost Berthold Date: Fri, 1 Aug 2025 16:31:40 +1000 Subject: [PATCH 2/3] add test for struct holding a reference (from last PR) --- .../data/prove-rs/struct_with_ref.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 kmir/src/tests/integration/data/prove-rs/struct_with_ref.rs diff --git a/kmir/src/tests/integration/data/prove-rs/struct_with_ref.rs b/kmir/src/tests/integration/data/prove-rs/struct_with_ref.rs new file mode 100644 index 000000000..518520108 --- /dev/null +++ b/kmir/src/tests/integration/data/prove-rs/struct_with_ref.rs @@ -0,0 +1,21 @@ +struct WithRef<'a> { + a_ref: &'a AThing, +} + +struct AThing { + a_field: i8, + another: i16, +} + +fn main() { + let a_thing = AThing{ a_field: 1, another: 2}; + let a_ref = &a_thing; + let with_ref = WithRef{a_ref}; + + assert!(with_ref.a_ref.a_field == 1 && a_thing.another == 2); // works + f(with_ref); +} + +fn f(w: WithRef) { + assert!(2 * w.a_ref.a_field as i16 == w.a_ref.another); +} \ No newline at end of file From ffe1f82f51c981dfecab875600de4ddfb61cfc94 Mon Sep 17 00:00:00 2001 From: Jost Berthold Date: Tue, 5 Aug 2025 10:14:37 +1000 Subject: [PATCH 3/3] HOTFIX add offset to ty in array size tyconst --- kmir/src/kmir/linker.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kmir/src/kmir/linker.py b/kmir/src/kmir/linker.py index 21d3d04eb..3a5716c0c 100644 --- a/kmir/src/kmir/linker.py +++ b/kmir/src/kmir/linker.py @@ -80,6 +80,8 @@ def apply_offset_typeInfo(typeinfo: dict, offset: int) -> dict: typeinfo['UnionType']['adt_def'] = typeinfo['UnionType']['adt_def'] + offset elif 'ArrayType' in typeinfo: typeinfo['ArrayType']['elem_type'] = typeinfo['ArrayType']['elem_type'] + offset + if 'size' in typeinfo: + apply_offset_tyconst(typeinfo['size'], offset) elif 'PtrType' in typeinfo: typeinfo['PtrType']['pointee_type'] = typeinfo['PtrType']['pointee_type'] + offset elif 'RefType' in typeinfo: