[llvm] [Support] Add end/error to decode[US]LEB128AndInc (PR #90006)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 12:36:29 PDT 2024
dwblaikie wrote:
> Some `decode[US]LEB128AndInc` occurrences in `llvm/utils/TableGen/DecoderEmitter.cpp` omit `end`. Making `end` non-default would need to update them where there isn't a good parameter...
Not sure I follow this - the good parameter to use for this case would be the end of the buffer.
It looks like the not code-generated parts of this code already do such error checking (even if they only assert when there is an error) https://github.com/llvm/llvm-project/blob/e68d505008d878c6303032631fcfd5918b62f3d6/llvm/utils/TableGen/DecoderEmitter.cpp#L859-L861
It looks like if `decodeInstruction` took an ArrayRef instead of a pointer it wouldn't require updates to the caller (they pass in global arrays anyway, so ArrayRef's length deduction would kick in) and then the buffer length would be known/could be passed in (well, `length - (ptr - data)` I suppose, which is admittedly a bit annoying and maybe there's a better way to manage that) to the decodeULEB128 calls.
Anyway, at least this'll do for now I guess - thanks!
https://github.com/llvm/llvm-project/pull/90006
More information about the llvm-commits
mailing list