[PATCH] D34570: [DWARF] NFC: Collect info needed by DWARFFormValue into a helper

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 18:36:18 PDT 2017


(Re-adding llvm-commits yet again)
Of course I write all that *before* looking at the caller you mentioned… which does in fact already look at the forms.  Gah!  I now think you are right, it probably can be recoded to avoid needing the extra method.  I'll look at it again on Monday.
Thanks,
--paulr


From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf Of Robinson, Paul via llvm-commits
Sent: Friday, June 23, 2017 6:29 PM
To: David Blaikie; reviews+D34570+public+9d5e31ef9b3178e4 at reviews.llvm.org; aprantl at apple.com
Cc: clayborg at gmail.com; hiraditya at msn.com; llvm-commits at lists.llvm.org
Subject: RE: [PATCH] D34570: [DWARF] NFC: Collect info needed by DWARFFormValue into a helper

I'm still sort of uncertain how this is OK for abbrevs...

Greg explained this to me at the last LLVM dev meeting.  If you have read in a .debug_info section and want to build a table of pointers to DIEs as quickly as possible, you really don't want to be looking at the content of each DIE if you can help it.  You want to know ahead of time how big each DIE is, if at all possible.  Then you can build your table by looking at just the abbrev number.  "Abbrev 12: 40 bytes. Abbrev 10: 10 bytes."  You don't have to decode anything, until you get to "Abbrev 18: not fixed size."  Then you have to actually parse the DIE to see how big it is.

So, you scan the abbrev table first, to figure out the size for each abbrev.  But if that scan depends on the Unit (for version/format info) then you have to re-scan the abbrev table for every unit.  That's a waste because probably 95% of the time, the answers don't actually depend on the version/format (there are only 6 forms that have this dependency, plus two GNU extensions).  So, you scan the abbrev table up front once, accepting that any abbrevs that DO depend on version/format will show up as "not fixed size" because ultimately it is actually faster that way.  At least according to Greg it is.

Technically the abbrev scanner could encode the knowledge of which forms have the dependency, and not call DWARFFormValue for those forms.  But, that's not good information-hiding practice.  DWARFFormValue *already knows* which forms have the dependency, the abbrev scanner doesn't have to know.  And that's good separation of responsibilities.
--paulr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170624/4a6520ea/attachment.html>


More information about the llvm-commits mailing list