-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm][AsmWriter] Don't skip zero-valued DwarfEnum MDField when ShouldSkipZero is not set #126044
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
Conversation
…dSkipZero is not set I ran into this whil working on a different patch where I'm emitting a zero-valued DWARF enum field which shouldn't be skipped. This patch checks the (currently unused) `ShouldSkipZero` before deciding to skip printing this field. Based on git history this seems like an oversight from the initial refactor that introduced this. We have a similar check in `printInt`. Wasn't sure how to best test this, but tests in an upcoming patch rely on this functionality.
@llvm/pr-subscribers-llvm-ir Author: Michael Buch (Michael137) ChangesI ran into this whil working on a different patch where I'm emitting a zero-valued DWARF enum field which shouldn't be skipped. This patch checks the (currently unused) Wasn't sure how to best test this, but tests in an upcoming patch rely on this functionality. Currently the only place Full diff: https://github.com/llvm/llvm-project/pull/126044.diff 1 Files Affected:
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index c8ed4e19f1b612..57e9cccdc0fb6e 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2004,7 +2004,7 @@ void MDFieldPrinter::printNameTableKind(StringRef Name,
template <class IntTy, class Stringifier>
void MDFieldPrinter::printDwarfEnum(StringRef Name, IntTy Value,
Stringifier toString, bool ShouldSkipZero) {
- if (!Value)
+ if (ShouldSkipZero && !Value)
return;
Out << FS << Name << ": ";
|
…#126045) This is the 2nd part to #124752. Here we make sure to set the `DICompositeType` `EnumKind` if the enum was declared with `__attribute__((enum_extensibility(...)))`. In DWARF this will be rendered as `DW_AT_APPLE_enum_kind` and will be used by LLDB when creating `clang::EnumDecl`s from debug-info. Depends on #126044
…y attribute (#126045) This is the 2nd part to llvm/llvm-project#124752. Here we make sure to set the `DICompositeType` `EnumKind` if the enum was declared with `__attribute__((enum_extensibility(...)))`. In DWARF this will be rendered as `DW_AT_APPLE_enum_kind` and will be used by LLDB when creating `clang::EnumDecl`s from debug-info. Depends on llvm/llvm-project#126044
…dSkipZero is not set (llvm#126044) I ran into this while working on a different patch where I'm emitting a zero-valued DWARF enum field which shouldn't be skipped. This patch checks the (currently unused) `ShouldSkipZero` before deciding to skip printing this field. Based on git history this seems like an oversight from the initial refactor that introduced this. We have a similar check in `printInt`. Wasn't sure how to best test this, but tests in an upcoming patch rely on this functionality (see llvm#126045). Currently the only place `ShouldSkipZero` is set to `false` is when emitting the `DW_LANG_` enum. But the language codes start at `0x1`. So it never exercised this codepath (and we should probably just make it not pass this parameter).
…llvm#126045) This is the 2nd part to llvm#124752. Here we make sure to set the `DICompositeType` `EnumKind` if the enum was declared with `__attribute__((enum_extensibility(...)))`. In DWARF this will be rendered as `DW_AT_APPLE_enum_kind` and will be used by LLDB when creating `clang::EnumDecl`s from debug-info. Depends on llvm#126044
I ran into this while working on a different patch where I'm emitting a zero-valued DWARF enum field which shouldn't be skipped.
This patch checks the (currently unused)
ShouldSkipZero
before deciding to skip printing this field. Based on git history this seems like an oversight from the initial refactor that introduced this. We have a similar check inprintInt
.Wasn't sure how to best test this, but tests in an upcoming patch rely on this functionality (see #126045).
Currently the only place
ShouldSkipZero
is set tofalse
is when emitting theDW_LANG_
enum. But the language codes start at0x1
. So it never exercised this codepath (and we should probably just make it not pass this parameter).