This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Fix misleading using of DWARF forms with DIELabel. NFCI.
ClosedPublic

Authored by ikudrin on Jul 18 2020, 4:39 AM.

Details

Summary

DIELabel can emit only 32- or 64-bit values, while it was created in some places with DW_FORM_udata, which implies emitting uleb128. Nevertheless, these places also expected to emit U32 or U64, but just used a misleading DWARF form. The patch updates those places to use more appropriate DWARF forms and restricts DIELabel::SizeOf() to accept only forms that are actually used in the LLVM codebase.

See also: D83958.

Diff Detail

Event Timeline

ikudrin created this revision.Jul 18 2020, 4:39 AM

Ok, so we had incorrectly specified DW_FORM_udata for the label, but AddLabel had previously caused it to be emitted as an int32 anyway? So this doesn't change anything about the DWARF output?

@dschuff

It looks like you have been tweaking a number of related SizeOf() methods. Is it practical to have just one? In a parent class, or even as a free function (as the size computation depends only on form/format, and is not related to the class at all).

It looks like you have been tweaking a number of related SizeOf() methods. Is it practical to have just one? In a parent class, or even as a free function (as the size computation depends only on form/format, and is not related to the class at all).

The idea is that SizeOf() should be in sync with emitValue(). If a value class accepts a DWARF form, i.e. SizeOf() does not break on llvm_unreachable(), it should emit the value in the specified way, corresponding to that form.

Ok, so we had incorrectly specified DW_FORM_udata for the label, but AddLabel had previously caused it to be emitted as an int32 anyway? So this doesn't change anything about the DWARF output?

Exactly.

aardappel accepted this revision.Jul 21 2020, 11:09 AM
This revision is now accepted and ready to land.Jul 21 2020, 11:09 AM