After further discussion it has been determined that alignof should report 
the preferred alignment.  Thus, revert r135934, r135935, and r135940.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136062 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index a8d12ce..e09098e 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -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);
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index c6e2c20..5463b7b 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -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
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 1435627..fdcff0a 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -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) {
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index c7a87b2..7ea5146 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -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;
 
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 53f5c0a..3aebc41 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -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;
 
diff --git a/test/Sema/align-arm-apcs-gnu.c b/test/Sema/align-arm-apcs-gnu.c
deleted file mode 100644
index 575cf72..0000000
--- a/test/Sema/align-arm-apcs-gnu.c
+++ /dev/null
@@ -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];
diff --git a/test/Sema/align-arm-apcs.c b/test/Sema/align-arm-apcs.c
new file mode 100644
index 0000000..0a5d3fe
--- /dev/null
+++ b/test/Sema/align-arm-apcs.c
@@ -0,0 +1,4 @@
+// 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]; 
diff --git a/test/Sema/align-arm.c b/test/Sema/align-arm.c
deleted file mode 100644
index 68eb44d..0000000
--- a/test/Sema/align-arm.c
+++ /dev/null
@@ -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];