Repository navigation
[Attributor] Only follow addrspacecasts in AAPointerInfo - #225290
Conversation
AAPointerInfoFloating treated ptrtoaddr instructions, as well as ptrtoint and ptrtoaddr constant expressions, as pointer pass-through users. It then tracked the resulting integer as if it were a pointer and asserted in getPointerAddressSpace() once it reached a PHI. Handle all of them like a ptrtoint instruction, which already stops the analysis. Fixes llvm#221852.
|
Hello @LiRunGuo 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
@llvm/pr-subscribers-llvm-transforms Author: Gawr Gura 0721 (LiRunGuo) ChangesAAPointerInfoFloating treated ptrtoaddr instructions, as well as ptrtoint and The ptrtoint instruction was already excluded; this handles ptrtoaddr and the The constant-expression ptrtoint case is a separate crash with the same root Fixes #221852. Testing: check-llvm passes (Release+Asserts); added regression tests to 2 Files Affected:
The server is unavailable at this time. Please wait a few minutes before you try again. |
|
Hi @shiltian, could you please review this when you get a chance? AAPointerInfo currently treats In line with the LLVM AI Tool Use Policy, I've noted in the description that AI assistance was used. Assisted-by: Claude Thanks! |
shiltian
left a comment
There was a problem hiding this comment.
LGTM. PtrToAddrInst is a new thing after these AA work. It is very likely that other places that only check PtrToIntInst would need similar fix.
nikic
left a comment
There was a problem hiding this comment.
I think it would be preferable if this didn't do "follow all casts apart from ptrtoint and ptrtoaddr" and instead explicitly supported the casts that are supported.
The only casts this can reasonably follow are bitcast and addrspacecast.
For bitcast something to keep in mind is that a pointer can be casted to a byte type nowadays -- does this code handle that correctly? If not, it probably just shouldn't follow though bitcasts either, because pointer-to-pointer bitcasts do not naturally occur post opaque pointers.
So in that case it should just follow addrspacecasts and nothing else.
|
That is a good point. I think that makes sense too. I'm fine with landing this PR as is and then I'll do a follow up on it. |
|
Thanks @shiltian and @nikic! I've updated the patch to only follow addrspacecasts. Following a bitcast to a byte type did hit the same assertion once it reached a PHI, so I added a test for that. The only other test change is in I don't have commit access, so once CI passes, could one of you merge this on my behalf? Assisted-by: Claude |
There was a problem hiding this comment.
I think you can drop this entire block now. None of the following cases will match, and it will fall through to the unknown user case at the bottom.
There was a problem hiding this comment.
You can probably keep existing behavior on this test by dropping the %tmp20 = bitcast ptr %y to ptr line (replacing %tmp20 with %y).
|
Thanks @nikic! I've dropped the Assisted-by: Claude |
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) LLVMLLVM.CodeGen/AMDGPU/waterfall-loop-exec-update-terminator.mirIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
|
@LiRunGuo Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
AAPointerInfo followed every cast of a pointer except ptrtoint instructions. A ptrtoaddr, a ptrtoint/ptrtoaddr constant expression, or a bitcast to a byte type thus produced a non-pointer value that was tracked as a pointer, which asserted in getPointerAddressSpace() once it reached a PHI. Only follow addrspacecasts, the only casts that preserve the pointer. Fixes llvm#221852. Assisted-by: Claude
AAPointerInfo followed every cast of a pointer except ptrtoint instructions. A ptrtoaddr, a ptrtoint/ptrtoaddr constant expression, or a bitcast to a byte type thus produced a non-pointer value that was tracked as a pointer, which asserted in getPointerAddressSpace() once it reached a PHI. Only follow addrspacecasts, the only casts that preserve the pointer. Fixes llvm#221852. Assisted-by: Claude
AAPointerInfo followed every cast of a pointer except ptrtoint instructions. A ptrtoaddr, a ptrtoint/ptrtoaddr constant expression, or a bitcast to a byte type thus produced a non-pointer value that was tracked as a pointer, which asserted in getPointerAddressSpace() once it reached a PHI. Only follow addrspacecasts, the only casts that preserve the pointer. Fixes llvm#221852. Assisted-by: Claude
AAPointerInfo followed every cast of a pointer except ptrtoint instructions. A ptrtoaddr, a ptrtoint/ptrtoaddr constant expression, or a bitcast to a byte type thus produced a non-pointer value that was tracked as a pointer, which asserted in getPointerAddressSpace() once it reached a PHI. Only follow addrspacecasts, the only casts that preserve the pointer. Fixes llvm#221852. Assisted-by: Claude
AAPointerInfo followed every cast of a pointer except ptrtoint instructions. A ptrtoaddr, a ptrtoint/ptrtoaddr constant expression, or a bitcast to a byte type thus produced a non-pointer value that was tracked as a pointer, which asserted in getPointerAddressSpace() once it reached a PHI.
Only follow addrspacecasts, the only casts that preserve the pointer.
Fixes #221852.
Assisted-by: Claude