[PATCH] D100572: [DebugInfo] Ensure DIArgList in bitcode has no null or forward metadata refs
Stephen Tozer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 15 08:53:43 PDT 2021
StephenTozer created this revision.
StephenTozer added reviewers: dexonsmith, djtodoro, aprantl, pcc.
StephenTozer added a project: debug-info.
Herald added a subscriber: hiraditya.
StephenTozer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This solves an issue seen in a Chromium build <https://bugs.chromium.org/p/chromium/issues/detail?id=1198356#c1>, which resulted from incorrect bitcode read/write handling for `DIArgList`. The specific cause of the issue is that previously, when writing `DIArgList` to bitcode, there was no guarantee that all of its arguments had been written to bitcode beforehand. `DIArgList` is strict about its arguments, and will only accept `ValueAsMetadata*`, so forward MD references (temporary `MDNode*`s) are not valid when constructing a `DIArgList` object. It also meant that if a `ConstantAsMetadata` was only referenced in a `DIArgList`, it would not be written at all, resulting in a null record.
This issue was further obfuscated by the fact that `DIArgList` was not being stringent enough when reading and writing bitcode records; although `DIArgList` does not support null values for its arguments, it was allowing the argument records to be null.
This has been fixed by adding a new method to the `ValueEnumerator` to handle `DIArgList` that enumerates any `ConstantAsMetadata` arguments and contains a number of `DIArgList`-specific assertions. The read/write code has also been modified to appropriately assert that its arguments are non-null.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100572
Files:
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/lib/Bitcode/Writer/ValueEnumerator.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100572.337769.patch
Type: text/x-patch
Size: 4928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210415/358f3f30/attachment.bin>
More information about the llvm-commits
mailing list