[PATCH] D81562: [DebugInfo] Unify Cursor usage for all debug line opcodes
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 04:19:05 PDT 2020
jhenderson marked an inline comment as done.
jhenderson added inline comments.
================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:764
while (*OffsetPtr < EndOffset) {
+ DataExtractor::Cursor Cursor(*OffsetPtr);
+
----------------
MaskRay wrote:
> What about hoisting Cursor and refactoring more `*OffsetPtr` to use Cursor?
I considered that, but there are a few reasons not to:
1) We handle errors differently depending on context. For extended opcodes, we continue parsing, which means we want to reset the `Cursor` to a good state after handling them. Recreating it at the start of the loop is easier.
2) We'd have to do a no-op error check of the `Cursor`, to avoid an unchecked error situation in the event of an empty body.
3) The only parsing outside the loop is the Prologue parsing, which has its own `Cursor` and is self-contained (not all clients that parse the prologue parse the body), meaning it doesn't make much sense to pass in the `Cursor` from outside. There is therefore no need to share said `Cursor` with anything else. The only benefit in hoisting it is therefore to avoid needing to reinitialise the `Cursor` on each iteration (but see above why this isn't that helpful).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81562/new/
https://reviews.llvm.org/D81562
More information about the llvm-commits
mailing list