Fix overflow in number of bytes for long DMA BD lengths#3034
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an integer overflow when computing DMA buffer-descriptor lengths (elements → bytes / 32-bit words) so large transfers are validated and reported correctly, addressing #3033.
Changes:
- Widen BD length/offset calculations to 64-bit to prevent overflow during element-size multiplication.
- Update verifier alignment arithmetic to use 64-bit byte offsets.
- Add regression tests covering both “no false error” and “correct 64-bit diagnostic text” for very large lengths.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-good.mlir | Adds a regression test for a large transfer that would overflow 32-bit when converted to bytes. |
| test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-bad.mlir | Adds a regression test ensuring diagnostics report the correct (non-truncated) byte counts. |
| lib/Targets/AIETargetXAIEV2.cpp | Widens internal tracking of BD length/offset for XAIEV2 codegen. |
| lib/Dialect/AIE/IR/AIEDialect.cpp | Uses a 64-bit accumulator for base+offset byte alignment checks in DMABDOp::verify(). |
| include/aie/Dialect/AIE/IR/AIEOps.td | Changes DMABDOp::getLenInBytes() to 64-bit and makes offset-in-bytes 64-bit to avoid overflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
@copilot apply changes based on the comments in this thread |
hunhoffe
approved these changes
May 6, 2026
Collaborator
hunhoffe
left a comment
There was a problem hiding this comment.
Looks good! I had a few questions, but nothing blocking.
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.
closes #3033