[LLVM] Fix insertDbgValueIntrinsic for Metal backend#18706
Conversation
Summary of ChangesHello @MasterJH5574, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical compilation issue affecting the Metal backend when using specific LLVM versions. It refines how debug information is handled for different data types, ensuring compatibility with LLVM's stricter requirements for debug intrinsics. The changes enable successful compilation of previously failing TIR code for Metal. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix an LLVM issue for the Metal backend related to debug information generation. The main change in codegen_llvm.cc introduces the use of insertDbgValueIntrinsic for non-pointer types on LLVM 15+, which is correct in principle. However, the current implementation has two critical issues: it removes the existing insertDeclare logic, causing a regression for pointer types and older LLVM versions, and it has a bug in the new logic for LLVM versions 15-19. I've provided a detailed comment with a suggested fix. The changes in the Python test files seem fine.
Some TIR code could not be compiled to Metal due to an LLVM issue, as described in apache#18585. This PR fixes the issue according to the Option 2 in apache#18585 (comment). Unit tests are updated, though they are not enabled in CI for now.
22109ea to
ece6626
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a compilation issue for the Metal backend on LLVM 15+ by using insertDbgValueIntrinsic for non-pointer types in debug information generation. This change correctly handles SSA values that don't have a memory address, resolving an LLVM assertion failure. The changes in src/target/llvm/codegen_llvm.cc are well-structured with preprocessor directives to maintain compatibility across different LLVM versions. Additionally, unit tests have been updated to reflect new API usage and to include compile-only tests for Metal to verify the fix. My review includes a minor suggestion to improve the accuracy of a comment. Overall, the changes look good and effectively fix the described issue.
Some TIR code could not be compiled to Metal due to an LLVM issue, as described in #18585. This PR fixes the issue according to the Option 2 in
#18585 (comment).
Unit tests are updated, though they are not enabled in CI for now.