Skip to content

Commit 640d5bd

Browse files
committed
[llvm][AsmWriter] Don't skip zero-valued DwarfEnum MDField when ShouldSkipZero 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 (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).
1 parent d864437 commit 640d5bd

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
@@ -1968,7 +1968,7 @@ void MDFieldPrinter::printNameTableKind(StringRef Name,
19681968
template <class IntTy, class Stringifier>
19691969
void MDFieldPrinter::printDwarfEnum(StringRef Name, IntTy Value,
19701970
Stringifier toString, bool ShouldSkipZero) {
1971-
if (!Value)
1971+
if (ShouldSkipZero && !Value)
19721972
return;
19731973

19741974
Out << FS << Name << ": ";

0 commit comments

Comments
 (0)