<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 6, 2015 at 4:55 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On Jan 6, 2015, at 4:39 PM, Tobias Grosser <<a href="mailto:tobias@grosser.es">tobias@grosser.es</a>> wrote:<br>
><br>
> On 07.01.2015 01:33, David Blaikie wrote:<br>
>><br>
>><br>
>> On Tue, Jan 6, 2015 at 4:30 PM, Tobias Grosser <<a href="mailto:tobias@grosser.es">tobias@grosser.es</a><br>
>> <mailto:<a href="mailto:tobias@grosser.es">tobias@grosser.es</a>>> wrote:<br>
>><br>
>>    Author: grosser<br>
>>    Date: Tue Jan  6 18:30:01 2015<br>
>>    New Revision: 225326<br>
>><br>
>>    URL: <a href="http://llvm.org/viewvc/llvm-project?rev=225326&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=225326&view=rev</a><br>
>>    Log:<br>
>>    Do not use a const Twine here<br>
>><br>
>>    This has caused segfaults when using Polly in the context of Julia,<br>
>>    that are<br>
>>    not reproducible on my machine in 'make check-polly'.<br>
>><br>
>>    Modified:<br>
>>         polly/trunk/lib/CodeGen/IslExprBuilder.cpp<br>
>><br>
>>    Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp<br>
>>    URL:<br>
>>    <a href="http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=225326&r1=225325&r2=225326&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=225326&r1=225325&r2=225326&view=diff</a><br>
>>    ==============================================================================<br>
>>    --- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)<br>
>>    +++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Tue Jan  6 18:30:01 2015<br>
>>    @@ -112,7 +112,7 @@ Value *IslExprBuilder::createAccessAddre<br>
>>        const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(BaseId);<br>
>>        Base = SAI->getBasePtr();<br>
>>        assert(Base->getType()->isPointerTy() && "Access base should be<br>
>>    a pointer");<br>
>>    -  const Twine &BaseName = Base->getName();<br>
>>    +  auto BaseName = Base->getName();<br>
>><br>
>><br>
>> So what type does getName return? StringRef?<br>
><br>
> Base is an llvm::Value and llvm::Value's getName() function returns a StringRef, yes.<br>
><br>
> Are you saying I should not use 'auto' here? Or do you have an explanation for the memory corruption I am seeing?<br>
<br>
</div></div>Isn’t it possible that the issue was taking a Twine by reference?<br>
I mean the return object is a temporary StringRef, it will be destroyed unless bound to a temporary. However there is a Twine constructor which is called for the conversion here, so the temp is bound to the argument of the Twine ctor and its lifetime ends with the ctor.<br>
You Twine reference a destroyed StringRef after that.<br></blockquote><div><br>The rest of what you said is correct, but making the named local a Twine value instead of a Twine reference would not fix/help. The StringRef would still be temporary and destroyed by the time the Twine was used.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Mehdi<br>
<br>
<br>
<br>
><br>
> Cheers,<br>
> Tobias<br>
<div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
</div></div></blockquote></div><br></div></div>