Skip to content

Conversation

@jiel-nv
Copy link
Contributor

@jiel-nv jiel-nv commented Apr 16, 2025

This PR improves the debug info for local variables.

  1. Add a CUDA native lowering pass to the lowering pipeline, so that we can customize the numba cuda IR w/o affecting upstream numba.
  2. Switch the llvm intrinsic call "llvm.dbg.declare" to "llvm.dbg.value" in order to provide more accurate value tracking.
  3. Eliminate the user variable aliases (the .$1 variations) in DILocalVariable.
  4. Merge DILocalVariable nodes with same name and type but different lines by using cache.
  5. Merge the BooleanLiteral type into boolean type and merge the IntegerLiteral type into integer type.
  6. Add three unit tests.

Fixes nvbug#5027648, nvbug#5009771, nvbug#5120628.

@gmarkall gmarkall added the 3 - Ready for Review Ready for review by team label Apr 17, 2025
@gmarkall
Copy link
Contributor

@jiel-nv Many thanks for the PR! I'll add it to my queue to review, but note I'm OOO until next Tuesday, so will have to pick it up after then.

Comment on lines 16 to 20
and (
name not in self._singly_assigned_vars
or self._disable_sroa_like_opt
)
and not name.startswith("$")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I comment out all these checks then none of the debuginfo tests fail. It's not immediately obvious to me what these conditions are for (I was commenting them out to try to learn what they did by what breaks when I do that) - are they really needed? If so, what for? Are there additional tests needed to check for the conditions these handle?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now that the first two conditions are used in the superclass storevar() and suppresses storing the variable when they are true.

I think the last is because we don't emit debuginfo for internal names (those beginning with a $).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right.

Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this generally looks good - there is one suggestion on the diff which I think will save time for future readers of the code (it took me quite a while to work out).

@gmarkall gmarkall added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review Ready for review by team labels May 2, 2025
Adding comments explaining the conditions.

Co-authored-by: Graham Markall <[email protected]>
Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! I think this is good to merge now but will wait until after the CI fixes (#238) are done.

@gmarkall gmarkall added 4 - Waiting on reviewer Waiting for reviewer to respond to author 5 - Ready to merge Testing and reviews complete, ready to merge and removed 4 - Waiting on author Waiting for author to respond to review 4 - Waiting on reviewer Waiting for reviewer to respond to author labels May 3, 2025
@gmarkall gmarkall merged commit 200b1bf into NVIDIA:main May 3, 2025
35 checks passed
gmarkall added a commit to gmarkall/numba-cuda that referenced this pull request May 3, 2025
- Local variable debug info deduplication (NVIDIA#222)
- Fix package installation for wheels CI  (NVIDIA#238)
- Fix Invalid NVVM IR emitted when lowering shfl_sync APIs (NVIDIA#231)
- Add Bfloat16 Low++ Bindings (NVIDIA#166)
- Fix cuda.jit decorator inline (NVIDIA#181)
- Feature: cuda specific make_attribute_wrapper (NVIDIA#193)
- return a none tuple if no libdevice path is found (NVIDIA#234)
@gmarkall gmarkall mentioned this pull request May 3, 2025
gmarkall added a commit that referenced this pull request May 3, 2025
- Local variable debug info deduplication (#222)
- Fix package installation for wheels CI  (#238)
- Fix Invalid NVVM IR emitted when lowering shfl_sync APIs (#231)
- Add Bfloat16 Low++ Bindings (#166)
- Fix cuda.jit decorator inline (#181)
- Feature: cuda specific make_attribute_wrapper (#193)
- return a none tuple if no libdevice path is found (#234)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Testing and reviews complete, ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants