Skip to content

Commit

Permalink
[TBAA] Don't emit pointer-tbaa for void pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
fhahn committed Jan 9, 2025
1 parent 3d37aa1 commit 0f3de86
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/lib/CodeGen/CodeGenTBAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
PtrDepth++;
Ty = Ty->getPointeeType()->getBaseElementTypeUnsafe();
} while (Ty->isPointerType());

// While there are no special rules in the standards regarding void pointers
// and strict aliasing, emitting distinct tags for void pointers break some
// common idioms and there is no good alternative to re-write the code
// without strict-aliasing violations.
if (Ty->isVoidType())
return AnyPtr;

assert(!isa<VariableArrayType>(Ty));
// When the underlying type is a builtin type, we compute the pointee type
// string recursively, which is implicitly more forgiving than the standards
Expand Down

0 comments on commit 0f3de86

Please sign in to comment.