aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2021-04-21 16:56:38 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2021-04-22 12:03:33 +0100
commite5d844b5874488599dc79e788a2dd6efa02940fb (patch)
treec41cfeeb57a1064fd660a6b83cf77870b3b025d0 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parentbe2277fbf233cca8e1bd698fa9ab6de404001c3a (diff)
downloadllvm-e5d844b5874488599dc79e788a2dd6efa02940fb.zip
llvm-e5d844b5874488599dc79e788a2dd6efa02940fb.tar.gz
llvm-e5d844b5874488599dc79e788a2dd6efa02940fb.tar.bz2
[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
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index e36ce87..3a7edd4 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1876,7 +1876,7 @@ void ModuleBitcodeWriter::writeDIArgList(const DIArgList *N,
unsigned Abbrev) {
Record.reserve(N->getArgs().size());
for (ValueAsMetadata *MD : N->getArgs())
- Record.push_back(VE.getMetadataOrNullID(MD));
+ Record.push_back(VE.getMetadataID(MD));
Stream.EmitRecord(bitc::METADATA_ARG_LIST, Record, Abbrev);
Record.clear();