[clang] [TBAA] Emit distinct TBAA tags for pointers with different depths,types. (PR #76612)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 07:54:56 PDT 2024
================
@@ -185,10 +185,56 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
return getChar();
// Handle pointers and references.
- // TODO: Implement C++'s type "similarity" and consider dis-"similar"
- // pointers distinct.
- if (Ty->isPointerType() || Ty->isReferenceType())
- return createScalarTypeNode("any pointer", getChar(), Size);
+ //
+ // C has a very strict rule for pointer aliasing. C23 6.7.6.1p2:
+ // For two pointer types to be compatible, both shall be identically
+ // qualified and both shall be pointers to compatible types.
+ //
+ // This rule is impractically strict; we want to at least ignore CVR
----------------
AaronBallman wrote:
I agree with this for the default behavior, but I think we should still allow opting into the strict C conformance behavior so that users can sanitize the code for portability to stricter compilers (also, it may allow for different optimization impacts that users might care about... maybe). This can be follow-up work though.
https://github.com/llvm/llvm-project/pull/76612
More information about the cfe-commits
mailing list