This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Force users of DWARFDebugAbbrev to call parse before iterating
ClosedPublic

Authored by bulbazord on Jul 6 2023, 1:40 PM.

Details

Summary

In an attempt to make it easier to catch errors when parsing the
debug_abbrev section, we should force users to call parse before
calling begin. In a follow-up change, I will change the return type of
parse from void to Error.

I also explored using the fallible_iterator pattern instead of forcing
users to parse everything up front. I think it would be a useful and
interesting pattern to implement, but it would require more extensive
changes to both DWARFDebugAbbrev and its users. Because my top priority
is improving the safety around parsing debug_abbrev, I'm opting to
preserve existing behavior until I or somebody else has time to refactor
to be able to implement a fallible_iterator.

Diff Detail

Event Timeline

bulbazord created this revision.Jul 6 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 1:40 PM
bulbazord requested review of this revision.Jul 6 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 1:40 PM
bulbazord updated this revision to Diff 538847.Jul 10 2023, 3:14 PM

Fix bolt test failures

ayermolo added inline comments.Jul 10 2023, 4:54 PM
bolt/lib/Core/DebugData.cpp
1301 ↗(On Diff #538847)

Assuming my changes won't be reverted BOLT no longer uses this method.

fdeazeve accepted this revision.Jul 12 2023, 10:04 AM

This LGTM. It doesn't change the amount of work we do in advance, nor does it prevent us from implementing a lazy approach if we can measure performance issues, and it enables error checking in the future.

This revision is now accepted and ready to land.Jul 12 2023, 10:04 AM
bulbazord marked an inline comment as done.Jul 12 2023, 10:16 AM
bulbazord added inline comments.
bolt/lib/Core/DebugData.cpp
1301 ↗(On Diff #538847)

Good to know. For now, it was causing test failures so I'm going to land this with this change. It'll just go away when we're able to delete this method.

ayermolo added inline comments.Jul 12 2023, 10:37 AM
bolt/lib/Core/DebugData.cpp
1301 ↗(On Diff #538847)

This BOLT code is no longer in trunk...

bulbazord marked an inline comment as done.

Remove deleted BOLT code