[llvm-dev] how to convert value to size_t

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 17 01:51:37 PDT 2018


Hi Sangeeta,

On Tue, 17 Jul 2018 at 05:00, sangeeta chowdhary via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> How can I achieve this? How can I pass the address as size_t?

You have to know what size_t maps to for your platform and then use a
PtrToInt instruction to cast it to that instead of i8*. LLVM doesn't
store this information anywhere, but the answer is usually the same as
the pointer size (which you could obtain from the Module's
DataLayout).

Though to my mind passing a "void *" is more descriptive anyway, or
maybe a uintptr_t at a stretch.

Cheers.

Tim.


More information about the llvm-dev mailing list