<div dir="ltr"><div class="gmail_default"><blockquote type="cite"><div dir="ltr"><span style="font-size:12.8px">Hello Dear All,</span><div style="font-family:arial,sans-serif;font-size:12.8px">I am writing a LLVM pass in which I inject some metadata to the parent function, if the function belongs to OpenMp region. Then, I want to get the injected metadata(including an ID) using the following code but I do not get the expected result. tAs I check the instrumented LLVM IR code the metadata is inserted correctly in the expected regions but I just can't retrieve them. Could you please let me know how can I get this value here.(I am using llvm 3.9)</div><div style="font-family:arial,sans-serif;font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:small">currentRegion refers to the current function.</span><br></div><div style="font-family:arial,sans-serif;font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:small">ompRegionsUID is a counter to make each region's ID unique.</span><span style="font-family:arial,helvetica,sans-serif;font-size:small"><br></span></div><div style="font-family:arial,sans-serif;font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:small"><br></span></div><div><font face="arial, helvetica, sans-serif">What I am looking for is to extract the injected ID in the metadata of the current function.Which is an integer called </font>currrRegionId. I have also tried to cast he output of the getOperand() command but still no expected result.</div></div></blockquote><blockquote type="cite"><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:12.8px"><span style="font-family:arial,helvetica,sans-serif;font-size:small"><br></span></div></div></blockquote><blockquote type="cite" style="font-family:arial,sans-serif;font-size:12.8px"><div dir="ltr"><div><br></div><div><br></div><div>if(currentRegion->getMetadata(<wbr>"<a href="http://omp.region.id/" target="_blank">omp.region.ID</a>")==NULL)</div><div> {</div><div> Metadata *Ops[1] = {ConstantAsMetadata::get(<wbr>ConstantInt::get(Int32, ompRegionsUID++))}; </div><div> llvm::MDNode *N = llvm::MDNode::get(C, Ops);</div><div> currentRegion->setMetadata("<a href="http://omp.region.id/" target="_blank">om<wbr>p.region.ID</a>", N);</div><div> int currrRegionId =currentRegion->getMetadata("<a href="http://omp.region.id/" target="_blank">o<wbr>mp.region.ID</a>")->getOperand(0);</div><div> </div><div> errs()<<"Omp region number: " << currentRegion->getName()<<"<wbr>currentRegionId: " << currrRegionId << "\n";</div><div><br></div><div> } </div><div><br></div><div><br></div><div>Thank you in advance for your time and considerations,</div><div><br></div><div>Kind Regards,</div><div>Ehsan</div></div></blockquote></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><font color="#660000"><b><i><font size="2" face="arial, helvetica, sans-serif"><span></span>E.Amiryousefi</font><font face="comic sans ms, sans-serif"><span></span></font></i></b></font><br><br><br><br><br><br></div></div></div>
</div>