[llvm-dev] Changing @llvm.objectsize(i8*, i1)

George Burgess IV via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 20 19:23:22 PDT 2015


Hello friends!

I'm currently working on trying to improve __builtin_object_size support in
Clang and LLVM. After a few more patches on Clang land, I plan on modifying
LLVM a bit.

For those unfamiliar with the C intrinsic __builtin_object_size, here's a
high-level overview of it:
https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html

We have an LLVM intrinsic known as @llvm.objectsize(i8* Ptr, i1 Min). Clang
lowers calls of __builtin_object_size(ptr, type) to this intrinsic if it
can't accurately determine an answer on its own. This works well for (type
& 1) == 0, but is broken in a few ways when the low bit is set.

If type==1, we (LLVM) give the ideal answer at best, and a conservatively
correct answer at worst.
If type==3, LLVM can give nothing but 0 (cannot determine), because we need
a lower bound, and we don't know subobject information.

In order to fix this, I plan on doing the following:
- Changing @llvm.objectsize(i8* Ptr, i1 Min) to @llvm.objectsize(i8* Ptr,
i8 Flags)
- [Design is ongoing] Adding metadata to select GEPs to track size
information. See here:
https://docs.google.com/document/d/1D5GibUI2RCCfa3g1zb5-3a7-l7nY1-tm3jrYciLP8dI/edit?usp=sharing

Thanks,
George
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150820/ec48e103/attachment-0001.html>


More information about the llvm-dev mailing list