-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][LLVM] add dwarfAddressSpace to DIDerivedType #92043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8c0b74
[MLIR][LLVM] add dwarfAddressSpace to DIDerivedType
willghatch da85cfd
review edits
willghatch f84b4f7
extend C-API doc string
willghatch 945c474
formatting...
willghatch 328e19b
oops, fix test that I was uncareful in writing
willghatch 01af344
add round-trip test
willghatch e128b05
use constant in C API test
willghatch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modeling this as an optional optional seems a bit odd. Do you know if there is a sematnic difference between zero and
std::nullopt
? If there is none, it would be nicer to model this asOptionalParameter<"uint32_t">
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the design follows LLVM in this regard. Using an integer would solve the CAPI issue but then it is also a slight difference with regards to LLVM (i.e. when round tripping MLIR would suddenly add extra address space information, which may be ok).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In one sense, I believe there is not a semantic difference in terms of what the debuginfo means between having no dwarf address space field and having a zero field, but the underlying LLVM implementation will do different things when it gets
std::nullopt
vs 0, IE omitting the field or emitting an attribute specifyingDW_AT_address_class
as 0. For cases where you aren't targetting a GPU, it makes more sense to omit the attribute even if there is no semantic difference between a lack of attribute and a zero value. Additionally, I'm not certain that all uses of theDW_AT_address_class
attribute do ensure that zero is the same as lack of an attribute (IE there may be targets where there is a semantic difference that I'm unaware of). I mainly modeled this to capture the behaviors of the underlying LLVM implementation, but I'll do a bit of digging to try to see whether it matters.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is something that's entirely target-defined, so as long as there's a difference in spec between nullopt & 0, it's probably safer to also keep the optional representation in MLIR to avoid any weird bugs down the road?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I thought it didn't, but it appears DWARF (v5, ch. 7.13) specifies a common
DW_ADDR_none
as 0. From ch. 2.12:I still think that if we want to adopt this, we should probably either remove the optional from the LLVM side, or at least translate 0 as nullopt into LLVM. It does mean we lose one degree of freedom, which is controlling whether the 0 address space actually gets emitted or not in DWARF (it's not clear if that should make a difference).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found anything indicating that lack of DW_AT_address_class is necessarily assumed to be different from a zero value, but I think there is practical value to being able to not emit the attribute when not dealing with GPUs as well as explicitly emit 0 when you are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah I 100% agree on the part about not emitting the 0 attribute for space saving in the general case. I'm less sure if we need to emit it for certain targets though (it's possible some targets have their quirks).
Though if it was a target-based rule on whether to emit 0, we can encode that in the llvm backend for that target. The frontend should not have to worry about it.
Now are there non-target-based rules? I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, @zyx-billy , I hadn't even seen your comments when I made mine, github's UI refreshing is inconsistent between top-level and thread comments... Yeah, maybe we should remove the optionality entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That keeps happening to me, I need to remember to refresh the page each time before I write a comment to check if others have come in...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha yeah me too, it's not always consistent about auto-updating these messages 🤦. OK yeah if you also think it's ok to just use DW_ADDR_none we can do that and simplify away this c-api problem too. It would be nice to change llvm too, though of course that's out of scope for this PR 😂 we can do that later if we want.