[cfe-commits] r136062 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/AST/ASTContext.cpp lib/AST/ExprConstant.cpp lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp test/Sema/align-arm-apcs-gnu.c test/Sema/align-arm-apcs.c test/Sema/align-arm.c

Chad Rosier mcrosier at apple.com
Tue Jul 26 00:03:04 PDT 2011


Author: mcrosier
Date: Tue Jul 26 02:03:04 2011
New Revision: 136062

URL: http://llvm.org/viewvc/llvm-project?rev=136062&view=rev
Log:
After further discussion it has been determined that alignof should report 
the preferred alignment.  Thus, revert r135934, r135935, and r135940.

Added:
    cfe/trunk/test/Sema/align-arm-apcs.c
      - copied unchanged from r135933, cfe/trunk/test/Sema/align-arm-apcs.c
Removed:
    cfe/trunk/test/Sema/align-arm-apcs-gnu.c
    cfe/trunk/test/Sema/align-arm.c
Modified:
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=136062&r1=136061&r2=136062&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jul 26 02:03:04 2011
@@ -88,7 +88,6 @@
 
   unsigned HasAlignMac68kSupport : 1;
   unsigned RealTypeUsesObjCFPRet : 3;
-  unsigned UsePreferredTypeAlign : 1;
 
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const std::string &T);
@@ -273,12 +272,6 @@
     return HasAlignMac68kSupport;
   }
 
-  /// usePreferredTypeAlign - Check whether this target uses minimum alignment
-  /// defined by ABI or some other preferred alignment.
-  bool usePreferredTypeAlign() const {
-    return UsePreferredTypeAlign;
-  }
-
   /// getTypeName - Return the user string for the specified integer type enum.
   /// For example, SignedShort -> "short".
   static const char *getTypeName(IntType T);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=136062&r1=136061&r2=136062&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 26 02:03:04 2011
@@ -696,10 +696,7 @@
         // Walk through any array types while we're at it.
         T = getBaseElementType(arrayType);
       }
-      if (Target.usePreferredTypeAlign())
-        Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
-      else
-        Align = std::max(Align, getTypeAlign(T.getTypePtr()));
+      Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
     }
 
     // Fields can be subject to extra alignment constraints, like if

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=136062&r1=136061&r2=136062&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Jul 26 02:03:04 2011
@@ -1592,15 +1592,10 @@
   //   result shall be the alignment of the referenced type."
   if (const ReferenceType *Ref = T->getAs<ReferenceType>())
     T = Ref->getPointeeType();
- 
-  // __alignof defaults to returning the preferred alignment, but
-  // can be overridden by the specific target.
-  if (Info.Ctx.Target.usePreferredTypeAlign())
-    return Info.Ctx.toCharUnitsFromBits(
-      Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
-  else
-    return Info.Ctx.toCharUnitsFromBits(
-      Info.Ctx.getTypeAlign(T.getTypePtr()));
+
+  // __alignof is defined to return the preferred alignment.
+  return Info.Ctx.toCharUnitsFromBits(
+    Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
 }
 
 CharUnits IntExprEvaluator::GetAlignOfExpr(const Expr *E) {

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=136062&r1=136061&r2=136062&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Jul 26 02:03:04 2011
@@ -65,9 +65,6 @@
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;
 
-  // Default to using preferred type alignment.
-  UsePreferredTypeAlign = true;
-
   // Default to using the Itanium ABI.
   CXXABI = CXXABI_Itanium;
 

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=136062&r1=136061&r2=136062&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jul 26 02:03:04 2011
@@ -1978,13 +1978,11 @@
                              "v64:32:64-v128:32:128-a0:0:32-n32");
       }
 
-      // Default to using minimum alignment, not preferred.
-      UsePreferredTypeAlign = false;
+      // FIXME: Override "preferred align" for double and long long.
     } else if (Name == "aapcs") {
       // FIXME: Enumerated types are variable width in straight AAPCS.
-
     } else if (Name == "aapcs-linux") {
-
+      ;
     } else
       return false;
 

Removed: cfe/trunk/test/Sema/align-arm-apcs-gnu.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/align-arm-apcs-gnu.c?rev=136061&view=auto
==============================================================================
--- cfe/trunk/test/Sema/align-arm-apcs-gnu.c (original)
+++ cfe/trunk/test/Sema/align-arm-apcs-gnu.c (removed)
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 -triple arm-unknown-unknown -target-abi apcs-gnu -fsyntax-only -verify %s
-
-struct s0 { double f0; int f1; };
-char chk0[__alignof__(struct s0) == 4 ? 1 : -1];
-
-double g1;
-short chk1[__alignof__(g1) == 4 ? 1 : -1]; 
-short chk2[__alignof__(double) == 4 ? 1 : -1];
-
-long long g2;
-short chk1[__alignof__(g2) == 4 ? 1 : -1]; 
-short chk2[__alignof__(long long) == 4 ? 1 : -1];
-
-_Complex double g3;
-short chk1[__alignof__(g3) == 4 ? 1 : -1]; 
-short chk2[__alignof__(_Complex double) == 4 ? 1 : -1];

Removed: cfe/trunk/test/Sema/align-arm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/align-arm.c?rev=136061&view=auto
==============================================================================
--- cfe/trunk/test/Sema/align-arm.c (original)
+++ cfe/trunk/test/Sema/align-arm.c (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fsyntax-only -verify %s
-
-double g1;
-short chk1[__alignof__(g1) == 8 ? 1 : -1]; 
-short chk2[__alignof__(double) == 8 ? 1 : -1];
-
-long long g2;
-short chk1[__alignof__(g2) == 8 ? 1 : -1]; 
-short chk2[__alignof__(long long) == 8 ? 1 : -1];
-
-_Complex double g3;
-short chk1[__alignof__(g3) == 8 ? 1 : -1]; 
-short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];





More information about the cfe-commits mailing list