Skip to content

Commit 3f1cf0f

Browse files
author
Dan Gohman
committed
Unsigned types are TBAA-compatible with their signed counterparts.
Also, handle unknown types conservatively. llvm-svn: 116541
1 parent 0b5c743 commit 3f1cf0f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,34 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
4949
}
5050

5151
// For now, just emit a very minimal tree.
52-
const Type *CanonicalTy = Context.getCanonicalType(Ty);
53-
if (const BuiltinType *BTy = dyn_cast<BuiltinType>(CanonicalTy)) {
52+
if (const BuiltinType *BTy = dyn_cast<BuiltinType>(Ty)) {
5453
switch (BTy->getKind()) {
54+
// Charactar types are special and can alias anything.
5555
case BuiltinType::Char_U:
5656
case BuiltinType::Char_S:
5757
case BuiltinType::UChar:
5858
case BuiltinType::SChar:
59-
// Charactar types are special.
6059
return Char;
60+
61+
// Unsigned types can alias their corresponding signed types.
62+
case BuiltinType::UShort:
63+
return getTBAAInfo(Context.ShortTy);
64+
case BuiltinType::UInt:
65+
return getTBAAInfo(Context.IntTy);
66+
case BuiltinType::ULong:
67+
return getTBAAInfo(Context.LongTy);
68+
case BuiltinType::ULongLong:
69+
return getTBAAInfo(Context.LongLongTy);
70+
case BuiltinType::UInt128:
71+
return getTBAAInfo(Context.Int128Ty);
72+
73+
// Other builtin types.
6174
default:
6275
return MetadataCache[Ty] =
6376
getTBAAInfoForNamedType(BTy->getName(Features), Char);
6477
}
6578
}
6679

67-
return MetadataCache[Ty] = getTBAAInfoForNamedType("TBAA.other", Char);
80+
// For now, handle any other kind of type conservatively.
81+
return MetadataCache[Ty] = Char;
6882
}

0 commit comments

Comments
 (0)