<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 12/21/11 11:24 PM, Oksana Tkachuk wrote:
<blockquote
cite="mid:CALrgj2_RBs9XA+sAifEOJDBiANoFbBJgMHc9798B00XBW-McuA@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
Hello,<br>
Thank you very much for the pointers.<br>
I am are able to create new MDNodes, filled with some constants,
and attach them<br>
to llvm instructions. However, the metadata map is not getting
updated as expected.<br>
For example, instead of the expected new entry<br>
</blockquote>
<br>
If you look at PoolMDPass::runOnModule(), you'll see that the
MDNodes are stored in a container (ValueToPoolNodes) and that they
are added as operands to a NamedMDNode. I think you have to make
your MDNodes operands of a NamedMDNode in order to get them to work
properly.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:CALrgj2_RBs9XA+sAifEOJDBiANoFbBJgMHc9798B00XBW-McuA@mail.gmail.com"
type="cite"><br>
!n = metadata !{some values}<br>
<br>
we are getting<br>
<br>
!n = metadata !{null}<br>
<br>
Do you know what might be wrong? Do we need to enter the MDNodes
into the map explicitly?<br>
<br>
Thank you,<br>
Oksana<br>
<br>
<br>
<div class="gmail_quote">On Tue, Dec 20, 2011 at 7:25 PM, 陳韋任 <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:chenwj@iis.sinica.edu.tw">chenwj@iis.sinica.edu.tw</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="h5">> Dear llvm-ers,<br>
> I am trying to attach a customized metadata to llvm
instructions.<br>
> Let's say, I want to attach some number to each
instruction.<br>
> I am trying to use<br>
><br>
> void Instruction::setMetadata(unsigned KindID,
MDNode* Node)<br>
><br>
> but I am not sure how to create a brand new instance
of an MDNode.<br>
> Do you have any code samples demonstrating how to do
that?<br>
><br>
> Due to some tool dependencies, I am using LLVM 2.7<br>
<br>
</div>
</div>
`grep -r MDNode` in $LLVM_SOURCE may give you some examples.
I don't know if<br>
there is a doxygen for LLVM 2.7, but you can see
include/llvm/Metadata.h and<br>
unittests/VMCore/MetadataTest.cpp to know how to create a
MDNode. Below is code<br>
snipt taken form MetadataTest.cpp.<br>
<br>
---<br>
MDString *s1 = MDString::get(Context, StringRef(&x[0],
3));<br>
MDString *s2 = MDString::get(Context, StringRef(&y[0],
3));<br>
ConstantInt *CI = ConstantInt::get(getGlobalContext(),
APInt(8, 0));<br>
<br>
std::vector<Value *> V;<br>
V.push_back(s1);<br>
V.push_back(CI);<br>
V.push_back(s2);<br>
<br>
MDNode *n1 = MDNode::get(Context, &V[0], 3);<br>
---<br>
<br>
HTH,<br>
chenwj<br>
<font color="#888888"><br>
--<br>
Wei-Ren Chen (陳韋任)<br>
Computer Systems Lab, Institute of Information Science,<br>
Academia Sinica, Taiwan (R.O.C.)<br>
<a class="moz-txt-link-freetext" href="Tel:886-2-2788-3799">Tel:886-2-2788-3799</a> #1667<br>
Homepage: <a moz-do-not-send="true"
href="http://people.cs.nctu.edu.tw/%7Echenwj"
target="_blank">http://people.cs.nctu.edu.tw/~chenwj</a><br>
</font></blockquote>
</div>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>