Restrain SROA to prevent memory corruption#3868
Open
atgeller wants to merge 2 commits intoNVIDIA:mainfrom
Open
Restrain SROA to prevent memory corruption#3868atgeller wants to merge 2 commits intoNVIDIA:mainfrom
atgeller wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Signed-off-by: Adam Geller <adgeller@nvidiae.com>
Collaborator
Author
Command Bot: Processing... |
Signed-off-by: Adam Geller <adgeller@nvidiae.com>
Collaborator
Author
Command Bot: Processing... |
khalatepradnya
approved these changes
Feb 5, 2026
Collaborator
khalatepradnya
left a comment
There was a problem hiding this comment.
Thank you @atgeller !
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
| } | ||
|
|
||
| // CHECK: First result: 0 0 1 0 1 0 1 0 | ||
| // CHECK: Second result: 0 0 1 0 1 0 1 0 No newline at end of file |
Collaborator
There was a problem hiding this comment.
Can you add Python test as well? See example here - https://github.com/NVIDIA/cuda-quantum/pull/3807/changes.
4 tasks
| if (auto store = dyn_cast<cudaq::cc::StoreOp>(cast_user)) | ||
| continue; | ||
| return failure(); | ||
| } |
Collaborator
There was a problem hiding this comment.
Note that following are failing in CI -
Failed Tests (2):
CUDAQ :: Transforms/basic-sroa.qke
CUDAQ :: Transforms/sroa.qke
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.
Description
When an array is passed to
llvm.memcpy, it is cast from a!cc.ptr<!cc.array<i8 x 2>>to a!cc.ptr<i8>. However,SROA, when checking if it can scaralize an allocation, does not look past the cast, leading it to improperly scalarize the array, meaning only the first element is properly set when it is passed tollvm.memcpy. This seems to be the cause of #3806.This PR adds additional checks to ensure that the cast array is only used for loading and storing to prevent improper scalarization.