bugc: preserve function loc/sourceId through optimizer#223
Merged
Conversation
cloneFunction dropped the optional Ir.Function.loc and sourceId
fields, returning only { name, parameters, entry, blocks }. Since
the first optimization pass clones the module, every function lost
its declaration source info from optimization level 1 upward.
evmgen gates declaration emission on func.loc && func.sourceId, so
all invoke/return contexts lost their declaration source ranges at
optimized levels — measurably 3/3 declared at level 0, 0/3 at
levels 1-3 on the widget's runtimeInstructions path.
Copy loc/sourceId in cloneFunction's return so declarations survive
optimization. Adds a regression test asserting invoke/return
contexts still carry declaration at levels 1, 2, and 3 (with a
level-0 baseline).
Contributor
|
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.
The optimizer's
cloneFunctiondropped the optionalIr.Function.locandsourceIdfields, returning only{ name, parameters, entry, blocks }. Because the first optimization pass clones the module, every function lost its declaration source info from optimization level 1 upward.evmgen gates
declarationemission onfunc.loc && func.sourceId, so all invoke/return contexts lost their declaration source ranges at optimized levels.Evidence (widget path:
bytecode.runtimeInstructions)Before:
After:
Fix
Copy
loc/sourceIdincloneFunction's return so declarations survive optimization. This restores declaration source ranges on invoke/return (including the tailcall back-edge) at every optimized level — the levels where the docs demo runs.Changes
optimizer/optimizer.ts—cloneFunctionpreservesloc/sourceId.evmgen/optimizer-contexts.test.ts— regression test asserting invoke/return contexts still carrydeclarationat levels 1, 2, 3 (with a level-0 baseline).Verification
yarn build+ full bugc suite green (410 passed, 22 pre-existing skips).