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

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


On 18 October 2016 at 11:36, Sanjay Patel via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> There's something wrong with the StringRef usage while parsing the attribute string.

I expect you already know, but just in case...

The problem is you're creating (and returning) a StringRef made from a
temporary std::string in the function below.

> +TargetRecip
> +TargetLoweringBase::getTargetRecipForFunc(MachineFunction &MF) const {
> +  const Function *F = MF.getFunction();
> +  StringRef RecipAttrName = "reciprocal-estimates";
> +  if (!F->hasFnAttribute(RecipAttrName))
> +    return ReciprocalEstimates;
> +
> +  // Make a copy of the target's default reciprocal codegen settings.
> +  TargetRecip Recips = ReciprocalEstimates;
> +
> +  // Override any settings that are customized for this function.
> +  StringRef RecipString = F->getFnAttribute(RecipAttrName).getValueAsString();
> +  Recips.set(RecipString);
> +  return Recips;
> +}


More information about the llvm-commits mailing list