[polly] r225326 - Do not use a const Twine here

Tobias Grosser tobias at grosser.es
Tue Jan 6 23:45:56 PST 2015


On 07.01.2015 02:57, David Blaikie wrote:
>
>
> On Tue, Jan 6, 2015 at 4:39 PM, Tobias Grosser <tobias at grosser.es
> <mailto:tobias at grosser.es>> wrote:
>
>     On 07.01.2015 01:33, David Blaikie wrote:
>
>
>
>         On Tue, Jan 6, 2015 at 4:30 PM, Tobias Grosser
>         <tobias at grosser.es <mailto:tobias at grosser.es>
>         <mailto:tobias at grosser.es <mailto:tobias at grosser.es>>> wrote:
>
>              Author: grosser
>              Date: Tue Jan  6 18:30:01 2015
>              New Revision: 225326
>
>              URL:
>         http://llvm.org/viewvc/llvm-__project?rev=225326&view=rev
>         <http://llvm.org/viewvc/llvm-project?rev=225326&view=rev>
>              Log:
>              Do not use a const Twine here
>
>              This has caused segfaults when using Polly in the context
>         of Julia,
>              that are
>              not reproducible on my machine in 'make check-polly'.
>
>              Modified:
>                   polly/trunk/lib/CodeGen/__IslExprBuilder.cpp
>
>              Modified: polly/trunk/lib/CodeGen/__IslExprBuilder.cpp
>              URL:
>         http://llvm.org/viewvc/llvm-__project/polly/trunk/lib/__CodeGen/IslExprBuilder.cpp?__rev=225326&r1=225325&r2=__225326&view=diff
>         <http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=225326&r1=225325&r2=225326&view=diff>
>
>         ==============================__==============================__==================
>              --- polly/trunk/lib/CodeGen/__IslExprBuilder.cpp (original)
>              +++ polly/trunk/lib/CodeGen/__IslExprBuilder.cpp Tue Jan  6
>         18:30:01 2015
>              @@ -112,7 +112,7 @@ Value *IslExprBuilder::__createAccessAddre
>                  const ScopArrayInfo *SAI =
>         ScopArrayInfo::getFromId(__BaseId);
>                  Base = SAI->getBasePtr();
>                  assert(Base->getType()->__isPointerTy() && "Access base
>         should be
>              a pointer");
>              -  const Twine &BaseName = Base->getName();
>              +  auto BaseName = Base->getName();
>
>
>         So what type does getName return? StringRef?
>
>
>     Base is an llvm::Value and llvm::Value's getName() function returns
>     a StringRef, yes.
>
>     Are you saying I should not use 'auto' here?
>
>
> Wasn't what I was saying, but now I will ;) I think, if it's that
> subtle, it's probably worth being explicit

r225342

>     Or do you have an explanation for the memory corruption I am seeing?
>
>
> As the other parts of this email thread discussed, the StringRef is
> returned by value, and is thus a temporary in the expression. The Twine
> only takes a pointer/reference to it, so the Twine persists (due to
> reference lifetime extension stuff) but it refers to a StringRef that is
> destroyed.

Great. Thanks for the nice explanation.

Cheers,
Tobias





More information about the llvm-commits mailing list