<div dir="auto">Hi Markus,<div dir="auto">Since I'm working on an llvm plugin and I have access to the GEP object but I'm not really sure how to do what you told me would you be able to show it to me with few lines of code?</div><div dir="auto"><br></div><div dir="auto">Thanks</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 25, 2022, 07:04 Markus Böck <<a href="mailto:markus.boeck02@gmail.com">markus.boeck02@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">The easiest way to do so in my experience is to change the base operand to a null pointer of the type and then convert the result of the GEP to an integer using ptrtoint. That will give you the offset in bytes and a pass using the target info will constant fold it as well. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 25, 2022, 08:00 Alberto Barbaro via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div>so I'm trying to understand how to manually calculate the offset calculated by a GEP instruction. I found that this question was asked over 6 years ago on stackoverflow[1] as well but never got a real answer.</div><div><br></div><div>Since I need exactly the same, is there anyone willing to help me to understand how to calculate the offset?</div><div><br></div><div>Thanks<br></div><div><br></div><div><br></div><div>[1] <a href="https://stackoverflow.com/questions/32444497/determine-byte-offset-of-getelementptr" rel="noreferrer noreferrer" target="_blank">https://stackoverflow.com/questions/32444497/determine-byte-offset-of-getelementptr</a></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer noreferrer" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>