<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 4, 2014 at 3:06 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br><br><div class="gmail_quote"><div><div class="h5">On Fri Oct 31 2014 at 1:29:34 PM Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: dexonsmith<br>
Date: Fri Oct 31 15:13:11 2014<br>
New Revision: 220994<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220994&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=220994&view=rev</a><br>
Log:<br>
IR: MDNode => Value: Instruction::setMetadata()<br>
<br>
Change `Instruction::setMetadata()` API to accept `Value` instead of<br>
`MDNode`.  Part of PR21433.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/IR/<u></u>IRBuilder.h<br>
    llvm/trunk/include/llvm/IR/<u></u>Instruction.h<br>
    llvm/trunk/lib/IR/Metadata.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/<u></u>IRBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=220994&r1=220993&r2=220994&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/include/<u></u>llvm/IR/IRBuilder.h?rev=<u></u>220994&r1=220993&r2=220994&<u></u>view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/include/llvm/IR/<u></u>IRBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/IR/<u></u>IRBuilder.h Fri Oct 31 15:13:11 2014<br>
@@ -23,12 +23,12 @@<br>
 #include "llvm/IR/DataLayout.h"<br>
 #include "llvm/IR/Instructions.h"<br>
 #include "llvm/IR/LLVMContext.h"<br>
+#include "llvm/IR/Metadata.h"<br>
 #include "llvm/IR/Operator.h"<br>
 #include "llvm/IR/ValueHandle.h"<br>
 #include "llvm/Support/<u></u>CBindingWrapping.h"<br>
<br>
 namespace llvm {<br>
-  class MDNode;<br>
<br>
 /// \brief This provides the default implementation of the IRBuilder<br>
 /// 'InsertHelper' method that is called whenever an instruction is created by<br>
<br>
Modified: llvm/trunk/include/llvm/IR/<u></u>Instruction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=220994&r1=220993&r2=220994&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/include/<u></u>llvm/IR/Instruction.h?rev=<u></u>220994&r1=220993&r2=220994&<u></u>view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/include/llvm/IR/<u></u>Instruction.h (original)<br>
+++ llvm/trunk/include/llvm/IR/<u></u>Instruction.h Fri Oct 31 15:13:11 2014<br>
@@ -176,9 +176,9 @@ public:<br>
<br>
   /// setMetadata - Set the metadata of the specified kind to the specified<br>
   /// node.  This updates/replaces metadata if already present, or removes it if<br>
-  /// Node is null.<br>
-  void setMetadata(unsigned KindID, MDNode *Node);<br>
-  void setMetadata(StringRef Kind, MDNode *Node);<br>
+  /// MD is null.<br>
+  void setMetadata(unsigned KindID, Value *MD);<br>
+  void setMetadata(StringRef Kind, Value *MD);<br>
<br>
   /// \brief Drop unknown metadata.<br>
   /// Passes are required to drop metadata they don't understand. This is a<br>
<br>
Modified: llvm/trunk/lib/IR/Metadata.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=220994&r1=220993&r2=220994&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/IR/<u></u>Metadata.cpp?rev=220994&r1=<u></u>220993&r2=220994&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/IR/Metadata.cpp (original)<br>
+++ llvm/trunk/lib/IR/Metadata.cpp Fri Oct 31 15:13:11 2014<br>
@@ -600,9 +600,9 @@ StringRef NamedMDNode::getName() const {<br>
 // Instruction Metadata method implementations.<br>
 //<br>
<br>
-void Instruction::setMetadata(<u></u>StringRef Kind, MDNode *Node) {<br>
-  if (!Node && !hasMetadata()) return;<br>
-  setMetadata(getContext().<u></u>getMDKindID(Kind), Node);<br>
+void Instruction::setMetadata(<u></u>StringRef Kind, Value *MD) {<br>
+  if (!MD && !hasMetadata()) return;<br>
+  setMetadata(getContext().<u></u>getMDKindID(Kind), MD);<br>
 }<br>
<br>
 MDNode *Instruction::getMetadataImpl(<u></u>StringRef Kind) const {<br>
@@ -655,9 +655,12 @@ void Instruction::<u></u>dropUnknownMetadata(Ar<br>
<br>
 /// setMetadata - Set the metadata of of the specified kind to the specified<br>
 /// node.  This updates/replaces metadata if already present, or removes it if<br>
-/// Node is null.<br>
-void Instruction::setMetadata(<u></u>unsigned KindID, MDNode *Node) {<br>
-  if (!Node && !hasMetadata()) return;<br>
+/// MD is null.<br>
+void Instruction::setMetadata(<u></u>unsigned KindID, Value *MD) {<br>
+  if (!MD && !hasMetadata()) return;<br>
+</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+  // For now, we only expect MDNodes here.<br>
+  MDNode *Node = cast<MDNode>(MD);<br>
<br></blockquote><div><br></div></div></div><div>Hrm. Is cast guaranteed to assert?</div></div></blockquote><div><br></div><div>It is:<br><br><div>// cast<X> - Return the argument parameter cast to the specified type.  This</div><div>// casting operator asserts that the type is correct, so it does not return null</div><div>// on failure. ...</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_quote"><div> If not, could you add one please?</div><div><br></div><div>Thanks!</div><span class=""><font color="#888888"><div><br></div><div>-eric</div></font></span><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
   // Handle 'dbg' as a special case since it is not stored in the hash table.<br>
   if (KindID == LLVMContext::MD_dbg) {<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote></span></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>