OSDN Git Service

Move computation past early return
authorAditya Kumar <hiraditya@msn.com>
Mon, 26 Sep 2016 21:01:13 +0000 (21:01 +0000)
committerAditya Kumar <hiraditya@msn.com>
Mon, 26 Sep 2016 21:01:13 +0000 (21:01 +0000)
Reviewers:
        rafael
        spatel

Differential Revision: https://reviews.llvm.org/D24843

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282440 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Metadata.cpp

index 51ef2fa..d4312c8 100644 (file)
@@ -1154,14 +1154,13 @@ MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
 }
 
 void Instruction::dropUnknownNonDebugMetadata(ArrayRef<unsigned> KnownIDs) {
-  SmallSet<unsigned, 5> KnownSet;
-  KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
-
   if (!hasMetadataHashEntry())
     return; // Nothing to remove!
 
   auto &InstructionMetadata = getContext().pImpl->InstructionMetadata;
 
+  SmallSet<unsigned, 4> KnownSet;
+  KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
   if (KnownSet.empty()) {
     // Just drop our entry at the store.
     InstructionMetadata.erase(this);