This is there the equivalent of size_t in llvm

Some system libraries, such as malloc strlen, want or return the size_t parameter as a parameter.

  • What is the right choice in LLVM IR to interact with these features?
  • Is selection a task for the compiler?
  • Does LLVM IR have size_t type?
+6
source share
2 answers

At the LLVM level, size_t does not exist. This is a constructor in favor of the developer, which is typedef'd for the native type. Native types have a fixed size for the target architecture, and that is how the compiler presents them in LLVM bit code. Thus, on x86, size_t can be viewed by the front end as an unsigned long, which then writes to LLVM as i32 (since the LLVM assembly does not have an unsigned type).

+9
source

You can use size_t in llvm, this is a valid type that will be used as usual.

-2
source

Source: https://habr.com/ru/post/917060/