[llvm] r284513 - revert r284495: [Target] remove TargetRecip class

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 18 13:51:26 PDT 2016


On 18 October 2016 at 13:48, Tim Northover <t.p.northover at gmail.com> wrote:
> The problem is you're creating (and returning) a StringRef made from a
> temporary std::string in the function below.

Sorry, scanned through the e-mail too quickly. It's actually
getRecipEstimateForFunc that matches my descripton:

-static StringRef getRecipEstimateForFunc(MachineFunction &MF) {
-  const Function *F = MF.getFunction();
-  StringRef RecipAttrName = "reciprocal-estimates";
-  if (!F->hasFnAttribute(RecipAttrName))
-    return StringRef();
-
-  return F->getFnAttribute(RecipAttrName).getValueAsString();
-}

getTargetRecipForFunc also looks sketchy though. I think the
std::string will be destroyed at the end of the line (techically "full
expression", but that ends at the semi-colon so whatever).

Tim.


More information about the llvm-commits mailing list