This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Sync generation of parameter names in a function signature with the function body.
ClosedPublic

Authored by pavelkopyl on Feb 20 2023, 8:42 AM.

Details

Summary

This fixes parameter names mismatch in anonymous functions.

Diff Detail

Event Timeline

pavelkopyl created this revision.Feb 20 2023, 8:42 AM
pavelkopyl requested review of this revision.Feb 20 2023, 8:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2023, 8:42 AM
tra added a comment.Feb 27 2023, 6:55 PM

Thank you for the patch. I'm OK with the fix in principle, but would like to check if we could make parameter name generation common for both function signature and the parameter symbol.

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
2624

While this does seem to produce correct argument name, at least for the test example, I'm not convinced it's the best way to handle this. The issue is that we're still generating parameter symbol name here separately from where it gets generated for the function signature. Off the top of my head I do not recall where it happens and I didn't have time to track it down yet.

We should attempt to make sure that the name is guaranteed to be generated using the same algorithm. E.g. via a common helper function.

llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
4

The patch description and the test should be a bit more specific describing what the problem is.

AFAICT, the problem is that there's currently a mismatch between the parameter name we generate in the function signature (__unnamed_1_param_0) and the name we use when we refer to the parameter in the body of the function (_param_0). https://godbolt.org/z/dMEKe1anG

pavelkopyl added inline comments.Mar 5 2023, 6:43 PM
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
2624

Thank you for the review. I slightly refactored the code that generates param names to have all in one place.

llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
4

Done.

pavelkopyl updated this revision to Diff 502501.Mar 5 2023, 6:44 PM
  • Rebase
  • Refactor the code that generates param names to have all in one place.
tra accepted this revision.Mar 6 2023, 12:11 PM

Nice! I like that there's just one way to determine parameter name now.

llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
12–14

I'd move it down to the second function. When possible, checks should be placed close to the code that we're checking.

This revision is now accepted and ready to land.Mar 6 2023, 12:11 PM
pavelkopyl retitled this revision from [NVPTX] Use proper parameter names in anonymous functions. to [NVPTX] Sync generation of parameter names in a function signature with the function body..Mar 10 2023, 3:58 PM
pavelkopyl edited the summary of this revision. (Show Details)
  • Update the test according to review notes.
llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
12–14

Done.

This revision was landed with ongoing or failed builds.Mar 10 2023, 6:42 PM
This revision was automatically updated to reflect the committed changes.