[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 09:29:17 PST 2024
rjmccall wrote:
Hmm. We're talking here about C++'s type similarity rules, which come from C++ [conv.qual]p1:
> A cv-decomposition of a type T is a sequence of cv_i and P_i such that T is “cv_0 P_0 cv_1 P_1 ··· cv_n−1 P_n−1 cv_n U” for n ≥ 0, where each cv_i is a set of cv-qualifiers, and each P_i is “pointer to”, “pointer to member of class C_i of type”, “array of N_i”, or “array of unknown bound of”.
Okay, so we have pointers, member pointers, and arrays, and the upshot is that we need to be ignoring qualifiers on the pointee/element type recursively in all of these. In the current code, we're falling short of that in two ways:
- we're completely not walking into member pointers
- we're not recursively walking into arrays; we do look through them at the last step, but if it's an array of pointers, we won't keep applying the similarity rule to the pointee type
Your patch happens to conservatively fix both of these, but I think we should probably go ahead and fix the array issue now, and then maybe it's just member pointers that we need to bail out conservatively for. The right fix for the array issue is just that we need the loop to look through array structure at every step before it checks for another pointer type.
https://github.com/llvm/llvm-project/pull/116991
More information about the cfe-commits
mailing list