From 35303fd739705b9167fb2596175e5cb397921566 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 6 Dec 2014 02:29:44 +0000 Subject: IR: Disallow function-local metadata attachments Metadata attachments to instructions cannot be function-local. This is part of PR21532. llvm-svn: 223574 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 9f6d02f..72f823c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2359,8 +2359,12 @@ std::error_code BitcodeReader::ParseMetadataAttachment() { MDKindMap.find(Kind); if (I == MDKindMap.end()) return Error(BitcodeError::InvalidID); - Value *Node = MDValueList.getValueFwdRef(Record[i+1]); - Inst->setMetadata(I->second, cast(Node)); + MDNode *Node = cast(MDValueList.getValueFwdRef(Record[i+1])); + if (Node->isFunctionLocal()) + // Drop the attachment. This used to be legal, but there's no + // upgrade path. + break; + Inst->setMetadata(I->second, Node); if (I->second == LLVMContext::MD_tbaa) InstsWithTBAATag.push_back(Inst); } -- cgit v1.1