<div dir="ltr">the pointer points to the first element, and you walk backwards from there to find the header details about the bounds/etc?<br><br>In any case - I'd look at something like C++'s std::vector, which is a variable length array, and model your situation similarly. I doubt there's anything in particular you'll want to/be able to teach the optimizations about your situation (nothing especially special that they know about std::vector-like things either, that I know of - they maybe can deduce certain things about how the bounds relate, and they certainly can optimize a lot of std::vector usage) & debug info would probably look like std::vector, in that it'd be a custom type, etc. Though if my guess above was right about using prefix data to describe the bounds - that might be hard to model in DWARF & you might be better off not being "tricky" like that & modelling this closer to something that you could have written in C or C++ more naturally.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 4:14 AM Christoffer Lernö via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto" style="overflow-wrap: break-word;"><div>I’m considering building in variable arrays by implementing them as a stretchy buffer, that is a single allocation with header + elements with the pointer passed around pointing to the first element. (Example: <a href="https://www.gamasutra.com/blogs/NiklasGray/20180109/312683/Minimalist_container_library_in_C_part_1.php" target="_blank">https://www.gamasutra.com/blogs/NiklasGray/20180109/312683/Minimalist_container_library_in_C_part_1.php</a>)<br><br>Is there a good way to represent this in LLVM? I mean both in terms of helping the optimizer passes understand how the layout works and to make sure the debug info looks ok.<br><br><br>Best regards,<br>Christoffer</div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>