-
Notifications
You must be signed in to change notification settings - Fork 383
[MemoryBanking] Add a new field to keep track values to be erased #8039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/Transforms/MemoryBanking.cpp
Outdated
| auto defaultValue = rewriter.create<arith::ConstantOp>(loc, zeroAttr); | ||
| rewriter.create<scf::YieldOp>(loc, defaultValue.getResult()); | ||
|
|
||
| if (isa<BlockArgument>(loadOp.getMemref())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add loadOp.memref() to oldMemRefVals only when the value is a BlockArgument because only the BlockArgument will remain in the cleanUpOldMemRefs function; and the values that are not BlockArgument will all gets replaced and naturally no longer exists, thus not requiring any additional clean-ups.
It probably would be good to add this as a (bit more concise) comment here. It isn't clear otherwise to someone reading the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some suggested changes, do with them as you please. LGTM
…sed because they will become dangling reference if their load operations are replaced
…tement; add more comments regarding old memref values
18ea55a to
a30e274
Compare
committing them, thanks for the review! |
…ues that need to be cleaned up after memory banking is complete (llvm#8039)
This patch adds a new
oldMemRefValsfield to keep track of the originalmemrefvalues that should be erased, as opposed to the old approach that derivesoldMemRefValssimply frommemoryToBanksmap:circt/lib/Transforms/MemoryBanking.cpp
Line 382 in acc5075
The issue with the original approach is that some keys in the
memoryToBanksmap might become dangling references because they are replaced:circt/lib/Transforms/MemoryBanking.cpp
Line 182 in acc5075
We add
loadOp.memref()tooldMemRefValsonly when the value is aBlockArgumentbecause only theBlockArgumentwill remain in thecleanUpOldMemRefsfunction; and the values that are notBlockArgumentwill all gets replaced and naturally no longer exists, thus not requiring any additional clean-ups.