From: Dan Gohman Date: Thu, 14 Oct 2010 23:39:00 +0000 (+0000) Subject: Unsigned types are TBAA-compatible with their signed counterparts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9af2f83863eb27840a4eb17abefec906c078d8ea;p=clang Unsigned types are TBAA-compatible with their signed counterparts. Also, handle unknown types conservatively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp index 0039db81b4..bff9fa2605 100644 --- a/lib/CodeGen/CodeGenTBAA.cpp +++ b/lib/CodeGen/CodeGenTBAA.cpp @@ -49,20 +49,34 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) { } // For now, just emit a very minimal tree. - const Type *CanonicalTy = Context.getCanonicalType(Ty); - if (const BuiltinType *BTy = dyn_cast(CanonicalTy)) { + if (const BuiltinType *BTy = dyn_cast(Ty)) { switch (BTy->getKind()) { + // Charactar types are special and can alias anything. case BuiltinType::Char_U: case BuiltinType::Char_S: case BuiltinType::UChar: case BuiltinType::SChar: - // Charactar types are special. return Char; + + // Unsigned types can alias their corresponding signed types. + case BuiltinType::UShort: + return getTBAAInfo(Context.ShortTy); + case BuiltinType::UInt: + return getTBAAInfo(Context.IntTy); + case BuiltinType::ULong: + return getTBAAInfo(Context.LongTy); + case BuiltinType::ULongLong: + return getTBAAInfo(Context.LongLongTy); + case BuiltinType::UInt128: + return getTBAAInfo(Context.Int128Ty); + + // Other builtin types. default: return MetadataCache[Ty] = getTBAAInfoForNamedType(BTy->getName(Features), Char); } } - return MetadataCache[Ty] = getTBAAInfoForNamedType("TBAA.other", Char); + // For now, handle any other kind of type conservatively. + return MetadataCache[Ty] = Char; }