Skip to content

Commit ae3e60a

Browse files
committed
fix(kmir): preserve move effects for noop calls
1 parent 0950dcc commit ae3e60a

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

  • kmir/src/kmir/kdist/mir-semantics

kmir/src/kmir/kdist/mir-semantics/kmir.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,26 @@ where the returned result should go.
370370
rule isNoOpFunction(monoItemFn(symbol(""), _, noBody)) => true
371371
rule isNoOpFunction(_) => false [owise]
372372
373+
syntax KItem ::= #consumeNoOpArgs(Operands, MaybeBasicBlockIdx)
374+
| #consumeNoOpArg(Operand) [strict(1)]
375+
373376
// SMIR marks some semantically empty shims (e.g. drop glue for trivially droppable slices)
374-
// as NoOpSym. They have no body and should continue immediately without switching frames.
377+
// as NoOpSym. They have no body and should continue immediately without switching frames,
378+
// but `Move` arguments must still invalidate the caller locals that were moved into the call.
375379
rule [termCallNoOp]:
376-
<k> #execTerminatorCall(_, monoItemFn(symbol(""), _, noBody), _ARGS, _DEST, TARGET, _UNWIND, _SPAN) ~> _
377-
=> #continueAt(TARGET)
380+
<k> #execTerminatorCall(_, monoItemFn(symbol(""), _, noBody), ARGS, _DEST, TARGET, _UNWIND, _SPAN) ~> _
381+
=> #consumeNoOpArgs(ARGS, TARGET)
378382
</k>
379383
384+
rule <k> #consumeNoOpArgs(.Operands, TARGET) => #continueAt(TARGET) ... </k>
385+
386+
rule <k> #consumeNoOpArgs(OP:Operand MORE:Operands, TARGET)
387+
=> #consumeNoOpArg(OP) ~> #consumeNoOpArgs(MORE, TARGET)
388+
...
389+
</k>
390+
391+
rule <k> #consumeNoOpArg(_:Value) => .K ... </k>
392+
380393
// Regular function call - full state switching and stack setup
381394
rule [termCallFunction]:
382395
<k> #execTerminatorCall(FTY, FUNC, ARGS, DEST, TARGET, UNWIND, SPAN) ~> _
@@ -506,6 +519,9 @@ An operand may be a `Reference` (the only way a function could access another fu
506519
507520
syntax Operand ::= operandValue ( Value )
508521
522+
// Internal helper operand for already-evaluated runtime values.
523+
rule <k> operandValue(VAL) => VAL ... </k>
524+
509525
syntax KItem ::= #setArgsFromStack ( Int, Operands)
510526
| #setArgFromStack ( Int, Operand)
511527
| #execIntrinsic ( MonoItemKind, Operands, Place, Span )

0 commit comments

Comments
 (0)