<p>Yes, that is what I mean. :-) </p>
<div class="gmail_quote">On Mar 12, 2012 11:02 AM, "Fraser Cormack" <<a href="mailto:frasercrmck@gmail.com">frasercrmck@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Hi Gavin,<br>
<br>
Do you mean something along the lines of having my array struct as { i32,<br>
i32* } and then indexing it with a gep and allocating the appropriate memory<br>
when I learn of it?<br>
<br>
Thanks,<br>
Fraser<br>
<br>
<br>
Gavin Harrison-2 wrote:<br>
><br>
> Hi Fraser,<br>
><br>
> Is there anything preventing you from using a pointer for the second part<br>
> of the structure and allocating memory for it later?<br>
><br>
> Thanks,<br>
> Gavin<br>
><br>
> On Mar 12, 2012, at 10:35 AM, Fraser Cormack wrote:<br>
><br>
>><br>
>> Hi Duncan,<br>
>><br>
>><br>
>> Duncan Sands wrote:<br>
>>><br>
>>> Hi Fraser, it looks to me like you are smashing the stack.<br>
>>><br>
>>>> define void @main() nounwind {<br>
>>>> allocas:<br>
>>>>   %0 = alloca { i32, [0 x i32] }, align 8<br>
>>><br>
>>> ^ this allocates 4 bytes on the stack.<br>
>>><br>
>>>>   %2 = getelementptr inbounds { i32, [0 x i32] }* %0, i64 0, i32 1<br>
>>><br>
>>> ^ this gets a pointer to the byte after the 4 allocated bytes.<br>
>>><br>
>>>>   %3 = bitcast [0 x i32]* %2 to i8*<br>
>>>>   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* bitcast ([5 x i32]*<br>
>>>> @.gvar_array to i8*), i64 20, i32 4, i1 false)<br>
>>><br>
>>> This copies 20 bytes there, kaboom!<br>
>>><br>
>><br>
>> Such a painfully obvious answer, thank you! I'm assuming this is what<br>
>> happens when I use the unoptimized version of the code and call<br>
>><br>
>>>   %0 = alloca %MainClass<br>
>><br>
>> then transfer the array into that. If I'm taking a MainClass pointer into<br>
>> my<br>
>> <init> function, can I then just re-allocate it as a { i32, [5 x i32] }<br>
>> when<br>
>> I learn about the length? That doesn't sound like the nicest option. I'm<br>
>> not<br>
>> aware of a way of only allocating a part of a literal struct, is that<br>
>> possible?<br>
>><br>
>> Cheers,<br>
>> Fraser<br>
>> --<br>
>> View this message in context:<br>
>> <a href="http://old.nabble.com/LLI-Segfaulting-tp33486161p33486962.html" target="_blank">http://old.nabble.com/LLI-Segfaulting-tp33486161p33486962.html</a><br>
>> Sent from the LLVM - Dev mailing list archive at Nabble.com.<br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
<br>
--<br>
View this message in context: <a href="http://old.nabble.com/LLI-Segfaulting-tp33486161p33487147.html" target="_blank">http://old.nabble.com/LLI-Segfaulting-tp33486161p33487147.html</a><br>
Sent from the LLVM - Dev mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div>