summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-12-27 01:17:40 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-12-27 01:17:40 +0000
commitda32cc6176d8ca2cd9cf387f5818ae911c91dc3c (patch)
tree869f5687ac7998d51c8ffffafe24480bf7c7f1cb /lib
parent125ef76934f37e3fdc8ce4a2cc238850d06c5912 (diff)
downloadllvm-da32cc6176d8ca2cd9cf387f5818ae911c91dc3c.tar.gz
llvm-da32cc6176d8ca2cd9cf387f5818ae911c91dc3c.tar.bz2
llvm-da32cc6176d8ca2cd9cf387f5818ae911c91dc3c.tar.xz
Using Inst->setMetadata(..., NULL) should be safe to remove metadata even when
there is non of that type to remove. This fixes a crasher in the particular case where the instruction has metadata but no metadata storage in the context (this is only possible if the instruction has !dbg but no other metadata info). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Metadata.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index 9966433496..993df41b46 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/lib/VMCore/Metadata.cpp
@@ -470,9 +470,11 @@ void Instruction::setMetadata(unsigned KindID, MDNode *Node) {
}
// Otherwise, we're removing metadata from an instruction.
- assert(hasMetadataHashEntry() &&
- getContext().pImpl->MetadataStore.count(this) &&
+ assert((hasMetadataHashEntry() ==
+ getContext().pImpl->MetadataStore.count(this)) &&
"HasMetadata bit out of date!");
+ if (!hasMetadataHashEntry())
+ return; // Nothing to remove!
LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
// Common case is removing the only entry.