]> granicus.if.org Git - clang/commitdiff
Unsigned types are TBAA-compatible with their signed counterparts.
authorDan Gohman <gohman@apple.com>
Thu, 14 Oct 2010 23:39:00 +0000 (23:39 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 14 Oct 2010 23:39:00 +0000 (23:39 +0000)
Also, handle unknown types conservatively.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116541 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTBAA.cpp

index 0039db81b466e08c8750b045034cfed3f0027da8..bff9fa2605ba6c82c6c6dde063298c042f329aa5 100644 (file)
@@ -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<BuiltinType>(CanonicalTy)) {
+  if (const BuiltinType *BTy = dyn_cast<BuiltinType>(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;
 }