Skip to content

Commit 0f3de86

Browse files
committed
[TBAA] Don't emit pointer-tbaa for void pointers.
llvm#122116
1 parent 3d37aa1 commit 0f3de86

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
228228
PtrDepth++;
229229
Ty = Ty->getPointeeType()->getBaseElementTypeUnsafe();
230230
} while (Ty->isPointerType());
231+
232+
// While there are no special rules in the standards regarding void pointers
233+
// and strict aliasing, emitting distinct tags for void pointers break some
234+
// common idioms and there is no good alternative to re-write the code
235+
// without strict-aliasing violations.
236+
if (Ty->isVoidType())
237+
return AnyPtr;
238+
231239
assert(!isa<VariableArrayType>(Ty));
232240
// When the underlying type is a builtin type, we compute the pointee type
233241
// string recursively, which is implicitly more forgiving than the standards

0 commit comments

Comments
 (0)