Skip to content

handle heterogeneous arrays in flattening pass - #660

Draft
tim-hoffman wants to merge 114 commits into
mainfrom
th/296
Draft

handle heterogeneous arrays in flattening pass#660
tim-hoffman wants to merge 114 commits into
mainfrom
th/296

Conversation

@tim-hoffman

Copy link
Copy Markdown
Member

Summary

Update flattening pass to create a series of flattened structs for an array of heterogeneous structs.

Related issues

Fixes #296

@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74c9383a7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Results

  2 files  ± 0    2 suites  ±0   6m 40s ⏱️ +53s
423 tests +28  419 ✅ +28  4 💤 ±0  0 ❌ ±0 
846 runs  +56  838 ✅ +56  8 💤 ±0  0 ❌ ±0 

Results for commit 755ef86. ± Comparison against base commit 9f3b2a6.

♻️ This comment has been updated with latest results.

Base automatically changed from th/applymap_folding to main July 31, 2026 00:40
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf4ba11ae4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44d8aafd08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d350c0c4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5483b9f86e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0414c2294

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Block &newTemplateBody = newTemplate.getBodyRegion().front();
for (Attribute name : layout.remainingNames) {
FlatSymbolRefAttr nameSym = llvm::cast<FlatSymbolRefAttr>(name);
Operation *paramOp = symTables.getSymbolTable(parentTemplate).lookup(nameSym.getAttr());
assert(paramOp && "symbol must exist");
newTemplateBody.push_back(paramOp->clone());

P1 Badge Preserve sibling callees in partial templates

When the partially instantiated function contains a flat call to a sibling function in the original template, the cloned template contains only the remaining parameters, copied expressions, and newFunc; it does not contain that sibling. The flat callee consequently resolves relative to the new template and becomes an unknown symbol, so applyBodyConversions() rejects an otherwise valid partial instantiation. Copy referenced sibling functions recursively or rewrite such callees to a path that still resolves in the original template.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/Polymorphic/Transforms/FlatteningPass.cpp
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 755ef86fa9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2625 to +2626
for (OpOperand &use : result.getUses()) {
Operation *user = use.getOwner();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate unifiable-cast consumers before replacing reads

When a generic array read feeds poly.unifiable_cast to an independently concrete type, this dispatch falls through without checking the cast. For example, a read replaced with Cell<0> may validly have been cast from generic Cell<#id> to Cell<1> before scalarization; replacing its input makes the cast operands non-unifiable, and UnifiableCastOp::verify() then rejects the transformed IR. Fresh evidence after the other consumer-specific fixes is that the reviewed helper still has no UnifiableCastOp branch; reject the replacement when the concrete input cannot unify with the cast result.

Useful? React with 👍 / 👎.

Comment on lines +3126 to +3127
for (OpOperand &use : result.getUses()) {
Operation *user = use.getOwner();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check array writes before refining member reads

When a generic MemberReadOp feeds an array.write whose destination has an independently concrete element type, this consumer is ignored. A read that initially unifies with both Cell<0> from the refined member and a destination requiring Cell<1> is retagged to Cell<0>, leaving the unchanged array write invalid. Fresh evidence beyond the existing call/initializer guards is that this loop still has no WriteArrayOp case; decline the member refinement unless the destination element type accepts refinedType.

Useful? React with 👍 / 👎.

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.

llzk-flatten generates invalid code on circom example 2B

2 participants