[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #78526)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 23 14:22:15 PST 2024


bwendling wrote:

It matches my understanding too. There are more issues with `__bdos` that arose due to this discussion and related discussions with the GCC maintainers.

I'm exploring some ways of fixing this issue:

* As @efriedma-quic mentioned, generating the size calculation in the front end (thus eliminating the need for the intrinsic) would be difficult in the general case, but may be possible for some simpler ones. One benefit of generating the calculation instead of the intrinsic is a potential win for inlining.

* If the main issue is that we don't know the subtype information, maybe we could add the subtype as part of the `llvm.objectsize` intrinsic and use that instead of grappling with the whole object's type. I'm unsure if this will work correctly for all cases though. (I don't readily know of any transformation that changes a structure's layout. Does it exist?) It's similar to the `llvm.memory.region.decl` proposal, but less intrusive.

https://github.com/llvm/llvm-project/pull/78526


More information about the cfe-commits mailing list