<div dir="ltr"><span class="gmail-im">
</span>> I expect you already know, but just in case...<div class="gmail_extra"><br></div><div class="gmail_extra">You can generally assume I have no clue. :)<br><br></div><div class="gmail_extra">I tried to repro under valgrind on linux, but no luck. Also doesn't repro for me on macOS in either debug or release.<br><br></div><div class="gmail_extra">Is a solution to return a std::string rather than a StringRef because the string will then be an actual copy rather than a reference?<br></div><div class="gmail_extra"><br>static std::string getRecipEstimateForFunc(MachineFunction &MF) {<br>...<br>  return F->getFnAttribute(RecipAttrName).getValueAsString().str();<br>}<br><br><div class="gmail_quote">On Tue, Oct 18, 2016 at 2:51 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 18 October 2016 at 13:48, Tim Northover <<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>> wrote:<br>
> The problem is you're creating (and returning) a StringRef made from a<br>
> temporary std::string in the function below.<br>
<br>
</span>Sorry, scanned through the e-mail too quickly. It's actually<br>
getRecipEstimateForFunc that matches my descripton:<br>
<span class="gmail-"><br>
-static StringRef getRecipEstimateForFunc(<wbr>MachineFunction &MF) {<br>
-  const Function *F = MF.getFunction();<br>
-  StringRef RecipAttrName = "reciprocal-estimates";<br>
-  if (!F->hasFnAttribute(<wbr>RecipAttrName))<br>
-    return StringRef();<br>
-<br>
-  return F->getFnAttribute(<wbr>RecipAttrName).<wbr>getValueAsString();<br>
-}<br>
<br>
</span>getTargetRecipForFunc also looks sketchy though. I think the<br>
std::string will be destroyed at the end of the line (techically "full<br>
expression", but that ends at the semi-colon so whatever).<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div></div>