[cfe-commits] r116541 - /cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp

Dan Gohman gohman at apple.com
Thu Oct 14 16:39:00 PDT 2010


Author: djg
Date: Thu Oct 14 18:39:00 2010
New Revision: 116541

URL: http://llvm.org/viewvc/llvm-project?rev=116541&view=rev
Log:
Unsigned types are TBAA-compatible with their signed counterparts.
Also, handle unknown types conservatively.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=116541&r1=116540&r2=116541&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Thu Oct 14 18:39:00 2010
@@ -49,20 +49,34 @@
   }
 
   // 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;
 }





More information about the cfe-commits mailing list