Skip to content

Effect Analysis Prototype - #562

Draft
flandia wants to merge 11 commits into
hkust-taco:hkmc2from
flandia:flow-effect
Draft

flandia wants to merge 11 commits into
hkust-taco:hkmc2from
flandia:flow-effect

Conversation

@flandia

@flandia flandia commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

This artifact is endorsed by Anto

@flandia

flandia commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

wtf Codex stole my authorship

Comment thread hkmc2/shared/src/main/scala/hkmc2/codegen/flowAnalysis/FlowAnalysis.scala Outdated
@LPTK

LPTK commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Thanks!

As discussed,

  • let's add a flag to Assign nodes to determine their effectfulness. We should make sure not to treat local mutation as a nonlocal side effect;
  • do not use an effectful annotation (just use actual effects instead);
  • make the optimizer not run when the lifter is disabled, so we don't need to care about nested definitions;
  • merge this into the eta expansion pass (later: the megapass).

val fStrat = processResult(f)
val argsStrat = args.map(a => processResult(a.value))
if args.exists(_.spread.isDefined) then
// TODO: preserve callee-effect precision for spread calls without modeling their argument flow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ychenfo is this the same bug as discussed?

Comment thread hkmc2/shared/src/main/scala/hkmc2/codegen/flowAnalysis/FlowAnalysis.scala Outdated
Comment thread hkmc2/shared/src/main/scala/hkmc2/codegen/CompilationPipeline.scala Outdated
@LPTK
LPTK marked this pull request as draft September 21, 2026 10:37
flandia and others added 9 commits September 30, 2026 00:32
Use MayHaveEffects for the analysis marker and summary, and mayHaveEffects for the metadata field, getters, and local flag. Update the corresponding golden outputs.

Co-authored-by: Flandia <me@flandia.dev>
Run eta expansion only when definition lifting is enabled. Enable lifting in the eta regression suites and cover both settings with a minimal pure producer.

Co-authored-by: Flandia <me@flandia.dev>
Remove the remaining annotation representation, conflict checks, lowering case, and flow-analysis override after source-level support was removed. Preserve the trusted @pure override.

Co-authored-by: Flandia <me@flandia.dev>
Remove the standalone effect-analysis pass and configuration. Infer effects in the shared flow solver and include summaries in its debug output by default, with logEffects controlling reporting only.

Support curried stages and conservatively handle multi-list calls so inference can run unconditionally. Drop the constructor-effect switch, configure effect tests through #config, and stabilize summary ordering. Include the corresponding golden outputs.

Co-authored-by: Flandia <me@flandia.dev>
Carry annotations with rewritten function parameters and bodies so every definition builder consumes the eta rewrite's metadata. Remove stale @pure annotations when adding stages and mark extended calls as potentially effectful. Preserve existing deforestation annotations.

Co-authored-by: Flandia <me@flandia.dev>
Increment affine annotation indices when lifting adds a capture parameter list, so the annotation continues to describe the original stage. Update the eta-expansion golden output for a captured affine lambda.

Co-authored-by: Flandia <me@flandia.dev>
Adapt effect annotation checks and eta-expansion rewrites to upstream's explicit source locations. Preserve affine stage indices, effect flag names, and purity metadata cleanup.

Co-authored-by: Flandia <me@flandia.dev>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants