[llvm-dev] How to calculate the offset obtained via a GEP instruction

Alberto Barbaro via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 25 02:17:00 PST 2022


Thanks Nikita,
I'll try it and get back to you if I still have problem.

Thanks a lot for your help

Alberto

On Tue, Jan 25, 2022, 08:25 Nikita Popov <nikita.ppv at gmail.com> wrote:

> On Tue, Jan 25, 2022 at 8:00 AM Alberto Barbaro via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hi all,
>> 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.
>>
>> Since I need exactly the same, is there anyone willing to help me to
>> understand how to calculate the offset?
>>
>
> You can use GEPOperator::accumulateConstantOffset(). Or more generically,
> there is Value::stripAndAccumulateConstantOffsets(), which can look through
> multiple GEPs, bitcasts, etc.
>
> Regards,
> Nikita
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220125/ef13815a/attachment.html>


More information about the llvm-dev mailing list