Teach combineMetadata how to merge 'nonnull' metadata.
authorPhilip Reames <listmail@philipreames.com>
Tue, 21 Oct 2014 21:02:19 +0000 (21:02 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 21 Oct 2014 21:02:19 +0000 (21:02 +0000)
combineMetadata is used when merging two instructions into one.  This change teaches it how to merge 'nonnull' - i.e. only preserve it on the new instruction if it's set on both sources.  This isn't actually used yet since I haven't adjusted any of the call sites to pass in nonnull as a 'known metadata'.

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

lib/Transforms/Utils/Local.cpp

index ecbe94a7e39a8e29177a7b6062d3b7497e4037ca..ef54eb20446b721c6856e402006ca7770a0d9743 100644 (file)
@@ -1339,6 +1339,10 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsign
         // Only set the !invariant.load if it is present in both instructions.
         K->setMetadata(Kind, JMD);
         break;
+      case LLVMContext::MD_nonnull:
+        // Only set the !nonnull if it is present in both instructions.
+        K->setMetadata(Kind, JMD);
+        break;
     }
   }
 }