<div dir="ltr"><span style="font-size:12.8000001907349px">Hello friends!</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">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.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">For those unfamiliar with the C intrinsic __builtin_object_size, here's a high-level overview of it: <a href="https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html" target="_blank">https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html</a></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">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. </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">If type==1, we (LLVM) give the ideal answer at best, and a conservatively correct answer at worst. </div><div style="font-size:12.8000001907349px">If type==3, LLVM can give nothing but 0 (cannot determine), because we need a lower bound, and we don't know subobject information.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">In order to fix this, I plan on doing the following:</div><div style="font-size:12.8000001907349px">- Changing @llvm.objectsize(i8* Ptr, i1 Min) to @llvm.objectsize(i8* Ptr, i8 Flags)</div><div style="font-size:12.8000001907349px">- [Design is ongoing] Adding metadata to select GEPs to track size information. See here: <a href="https://docs.google.com/document/d/1D5GibUI2RCCfa3g1zb5-3a7-l7nY1-tm3jrYciLP8dI/edit?usp=sharing" target="_blank">https://docs.google.com/document/d/1D5GibUI2RCCfa3g1zb5-3a7-l7nY1-tm3jrYciLP8dI/edit?usp=sharing</a></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks,</div><div style="font-size:12.8000001907349px">George</div></div>