Skip to content

LLVM: add AggregateAllocaSplitting transformation#1649

Open
phate wants to merge 3 commits into
masterfrom
RvsdgTreePrinter-SplitableAllocas
Open

LLVM: add AggregateAllocaSplitting transformation#1649
phate wants to merge 3 commits into
masterfrom
RvsdgTreePrinter-SplitableAllocas

Conversation

@phate
Copy link
Copy Markdown
Owner

@phate phate commented May 10, 2026

No description provided.

@phate phate changed the title Rvsdg tree printer splitable allocas LLVM: add AggregateAllocaSplitting transformation May 10, 2026
@phate phate force-pushed the RvsdgTreePrinter-SplitableAllocas branch 3 times, most recently from e43c5b2 to 072fc75 Compare May 12, 2026 04:24
@phate phate marked this pull request as ready for review May 13, 2026 05:37
@phate phate requested a review from haved May 13, 2026 05:37
@phate phate force-pushed the RvsdgTreePrinter-SplitableAllocas branch 2 times, most recently from 5a6940f to 9187240 Compare May 16, 2026 10:49
@phate phate force-pushed the RvsdgTreePrinter-SplitableAllocas branch from 9870b70 to e049378 Compare May 16, 2026 11:19
@phate phate enabled auto-merge (squash) May 16, 2026 11:19
@phate
Copy link
Copy Markdown
Owner Author

phate commented May 16, 2026

@haved This one is now ready for review.

Copy link
Copy Markdown
Collaborator

@haved haved left a comment

Choose a reason for hiding this comment

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

Looks good. I have some comments you can look at it you'd like. The code for finding all users of the alloca and all users of the GEP is very similar, so it makes me wish for a "reverse tracer" in the future

namespace jlm::llvm
{

class AggregateAllocaSplitting final : public rvsdg::Transformation
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A comment explaining what the class does would be nice

: allocaNode(&allocaNode)
{}

rvsdg::SimpleNode * allocaNode = nullptr;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this value is assigned in the constructor I don't think it should have a default value. It should never actually be null?

AllocaTraceInfo allocaTraceInfo(allocaNode);

util::HashSet<rvsdg::Output *> visited;
util::HashSet<rvsdg::Output *> toVisit{ &address };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tovisit HashSet could instead be a simple queue, with the HashSet instead storing "visited or queued". I often call that hash set "seen", but it is not a great name.

"Unhandled owner region node type: ",
userRegion->node()->DebugString()));
// Silence compiler
return false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really need to return even after throwing? How would control flow continue after the throw? If it complains then by all means, I just don't understand why the compiler would give such a false positive

bool hasOnlyLoadsAndStores = true;

util::HashSet<rvsdg::Output *> visited;
util::HashSet<rvsdg::Output *> toVisit{ &address };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here, one hash set and one queue

JLM_ASSERT(index0 == 0);

auto elementAlloca = elementAllocaNodes[index1];
auto & routedAddress = rvsdg::RouteToRegion(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We do not memorize routing to regions here, so in the future it might be nice to do that to avoid giving extra work for CNE. Not a big issue now

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.

2 participants