Add IlProjection Typed depth via an importer per-instruction trace#616
Merged
Conversation
Completes IlProjection's parity with the old AnnotatedILEmitter's three depths. The Typed view annotates each instruction with the evaluation-stack types after it. Rather than a second stack simulator, the importer optionally emits a per-instruction trace (offset -> stack ResultTypes) as a byproduct of the single import it already runs: an optional `List<IlTracePoint>? trace` threaded Build -> BuildBlock, recorded right after each opcode's switch arm (prefix opcodes `continue` past it and are correctly excluded; honest stops `return` before it). Null in the product import path, so that path is byte-identical. IlProjection.Project(..., Typed) runs the traced import for types and reuses Decode for the instruction text + resolved operands — one decode, one simulation. The new view is post-instruction stack state with the pipeline's richer typing (e.g. `bool` for `ceq`), vs the old emitter's pre-instruction state; same information, an improved spelling (the gate is exact-or-better). Tests: +1 (per-instruction stack-type annotation); ILInspector.Decompiler.Tests 441 pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Completes
IlProjection's parity with the oldAnnotatedILEmitter's three depths (#615 shippedRaw/Structured). TheTypeddepth annotates each instruction with the evaluation-stack types after it:How — one simulation, not two
The stack types come from the importer's own stack simulation, not a second pass. The importer optionally emits a per-instruction trace as a byproduct of the single import it already runs:
List<IlTracePoint>? tracethreadedBuild→BuildBlock.switcharm, capturing the liveStack<IrExpression>'sResultTypes. Prefix opcodes (constrained./volatile./…)continuepast it and are correctly excluded; honest stopsreturnbefore it.IrImporter.Buildis byte-identical there (trace?.Addis a no-op).Project(…, Typed)runs the traced import for the types and reusesDecodefor the instruction text + resolved operands — one decode, one simulation.Parity note
The new view shows post-instruction stack state with the pipeline's richer typing (
boolforceq); the old emitter showed pre-instruction state andInt32. Same information, an improved spelling — consistent with the "exact-or-better" gate. The eventual annotated-IL consumer migration will diff against the old emitter and accept these as improvements.Scope
Adds
IlProjectionDepth.Typedand aninternal IlTracePointrecord. Still non-disruptive — no consumers migrated;IlProjectionnow has all three depths, completing the foundation before the consumer migration (MemberCodeProvider, harnessDumpStages) and deletion ofMethodBodyContext/MethodAnalysis/AnnotatedILEmitter.Tests
+1 (
Typed_AnnotatesPerInstructionStackTypes);ILInspector.Decompiler.Tests441 pass. The product import path is unchanged (trace null), so no golden-output impact.🤖 Generated with Claude Code