I'm not sure who to tag for review due to the breadth of this change, so I'm seeing if there are any kind souls out there. :)
In order to make __builtin_object_size do a better job, we need to enable @llvm.objectsize to give more accurate answers. Currently, @llvm.objectsize takes an i1 Min argument instead of a Type, so whether or not we want information about a subobject is lost. Currently, this preference is mostly[1] useless to LLVM, because we can't rely on LLVM's type information to determine the size of a subobject. However, as is alluded to in the diff, the current plan is to use metadata in order to pass this information along so LLVM can be more accurate.
Full proposal for the metadata is here: https://docs.google.com/document/d/1D5GibUI2RCCfa3g1zb5-3a7-l7nY1-tm3jrYciLP8dI/edit?usp=sharing
Accompanying patch for clang will be posted soon.
[1] - If Type = 3, this information is highly relevant, because LLVM can only return 0 in this case. Currently, Clang handles this for LLVM by substituting 0 where it would normally emit @llvm.objectsize(%ptr, 3).
&b[0] ?