[Bitcode] Ensure DIArgList in bitcode has no null or forward metadata refs
authorStephen Tozer <Stephen.Tozer@Sony.com>
Wed, 21 Apr 2021 15:56:38 +0000 (16:56 +0100)
committerStephen Tozer <Stephen.Tozer@Sony.com>
Thu, 22 Apr 2021 11:03:33 +0000 (12:03 +0100)
commite5d844b5874488599dc79e788a2dd6efa02940fb
treec41cfeeb57a1064fd660a6b83cf77870b3b025d0
parentbe2277fbf233cca8e1bd698fa9ab6de404001c3a
[Bitcode] Ensure DIArgList in bitcode has no null or forward metadata refs

This patch fixes an issue in which ConstantAsMetadata arguments to a
DIArglist, as well as the Constant values referenced by that metadata,
would not be always be emitted correctly into bitcode. This patch fixes
this issue firstly by searching for ConstantAsMetadata in DIArgLists
(previously we would only search for them when directly wrapped in
MetadataAsValue), and secondly by enumerating all of a DIArgList's
arguments directly prior to enumerating the DIArgList itself.

This patch also adds a number of asserts, and no longer treats the
arguments to a DIArgList as optional fields when reading/writing to
bitcode.

Differential Revision: https://reviews.llvm.org/D100572
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/lib/Bitcode/Writer/ValueEnumerator.h
llvm/test/DebugInfo/Generic/debug_value_list.ll