Skip to content

Commit 5492199

Browse files
authored
[llvm][AsmWriter] Don't skip zero-valued DwarfEnum MDField when ShouldSkipZero is not set (#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 #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).
1 parent f4e3b87 commit 5492199

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ void MDFieldPrinter::printNameTableKind(StringRef Name,
20042004
template <class IntTy, class Stringifier>
20052005
void MDFieldPrinter::printDwarfEnum(StringRef Name, IntTy Value,
20062006
Stringifier toString, bool ShouldSkipZero) {
2007-
if (!Value)
2007+
if (ShouldSkipZero && !Value)
20082008
return;
20092009

20102010
Out << FS << Name << ": ";

0 commit comments

Comments
 (0)