On Thu, Apr 25, 2013 at 3:14 PM, B B <blackbox.dev.ml at gmail.com> wrote:> > %call = call noalias i8* @_Znwm(i64 ptrtoint(%class.A* getelementptr(%class.A* null, i32 1) to i64)) > Yes, by "dynamically" I meant at IR code generation time. So if I > understand, in your approach I need only to determine how many elements are > in the structure. How can I get this value?Actually, you don't even need that. The "1" means "one full struct" rather than "after field 1" or anything similar. So it won't change depending on how many fields are in the struct. You might find this page from the docs useful: http://llvm.org/docs/GetElementPtr.html Tim.
Thank you! It works like a charm Regards 2013/4/25 Tim Northover <t.p.northover at gmail.com>> On Thu, Apr 25, 2013 at 3:14 PM, B B <blackbox.dev.ml at gmail.com> wrote: > > > %call = call noalias i8* @_Znwm(i64 ptrtoint(%class.A* > getelementptr(%class.A* null, i32 1) to i64)) > > Yes, by "dynamically" I meant at IR code generation time. So if I > > understand, in your approach I need only to determine how many elements > are > > in the structure. How can I get this value? > > Actually, you don't even need that. The "1" means "one full struct" > rather than "after field 1" or anything similar. So it won't change > depending on how many fields are in the struct. > > You might find this page from the docs useful: > http://llvm.org/docs/GetElementPtr.html > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130425/7a9d6606/attachment.html>
On Thu, Apr 25, 2013 at 3:50 PM, B B <blackbox.dev.ml at gmail.com> wrote:> Thank you! It works like a charmNo worries. I've just noticed a function ConstantExpr::getSizeOf which looks like it automates the process if you want to simplify your C++ code. Tim.