[IR] Call DenseMap::erase directly (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 12 Jun 2022 17:47:06 +0000 (10:47 -0700)
committerKazu Hirata <kazu@google.com>
Sun, 12 Jun 2022 17:47:06 +0000 (10:47 -0700)
We can erase an item in DenseMap without checking its membership first.

llvm/lib/IR/Globals.cpp

index 4f53f8e..d2ddfd4 100644 (file)
@@ -236,9 +236,7 @@ void GlobalValue::setSanitizerMetadata(const SanitizerMetadata &Meta) {
 void GlobalValue::removeSanitizerMetadata() {
   DenseMap<const GlobalValue *, SanitizerMetadata> &MetadataMap =
       getContext().pImpl->GlobalValueSanitizerMetadata;
-  auto It = MetadataMap.find(this);
-  if (It != MetadataMap.end())
-    MetadataMap.erase(It);
+  MetadataMap.erase(this);
   HasSanitizerMetadata = false;
 }