aeubanks created this revision.
aeubanks added reviewers: hans, rsmith.
Herald added a reviewer: aaron.ballman.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Followup to D110451 <https://reviews.llvm.org/D110451> which set LLVM's max 
allowed alignment to 2^32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111250

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp

Index: clang/test/SemaCXX/alloc-align-attr.cpp
===================================================================
--- clang/test/SemaCXX/alloc-align-attr.cpp
+++ clang/test/SemaCXX/alloc-align-attr.cpp
@@ -7,8 +7,8 @@
 
 template <typename T>
 struct dependent_ret {
-  T *Foo(unsigned a) __attribute__((alloc_align(2))); // no-warning, ends up being int**.
-  T Foo2(unsigned a) __attribute__((alloc_align(2))); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
+  T *Foo(unsigned long long a) __attribute__((alloc_align(2))); // no-warning, ends up being int**.
+  T Foo2(unsigned long long a) __attribute__((alloc_align(2))); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
 };
 
 // Following 2 errors associated only with the 'float' versions below.
@@ -32,8 +32,8 @@
   b.Foo2(1);
   b.Foo(3);           // expected-warning {{requested alignment is not a power of 2}}
   b.Foo2(3);          // expected-warning {{requested alignment is not a power of 2}}
-  b.Foo(2147483648);  // expected-warning {{requested alignment must be 1073741824 bytes or smaller; maximum alignment assumed}}
-  b.Foo2(2147483648); // expected-warning {{requested alignment must be 1073741824 bytes or smaller; maximum alignment assumed}}
+  b.Foo(8589934592ull);  // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
+  b.Foo2(8589934592ull); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
   b.Foo(align);
   b.Foo2(align);
 
Index: clang/test/Sema/builtin-assume-aligned.c
===================================================================
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -46,7 +46,7 @@
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
-void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(2147483648))); // expected-warning {{requested alignment must be 1073741824 bytes or smaller; maximum alignment assumed}}
+void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(8589934592ull))); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
 
 int j __attribute__((assume_aligned(8))); // expected-warning {{'assume_aligned' attribute only applies to Objective-C methods and functions}}
 void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
@@ -60,6 +60,6 @@
 void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
 
 int pr43638(int *a) {
-  a = __builtin_assume_aligned(a, 2147483648); // expected-warning {{requested alignment must be 1073741824 bytes or smaller; maximum alignment assumed}}
+  a = __builtin_assume_aligned(a, 8589934592); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
   return a[0];
 }
Index: clang/test/Sema/attr-aligned.c
===================================================================
--- clang/test/Sema/attr-aligned.c
+++ clang/test/Sema/attr-aligned.c
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
 
 int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
-int y __attribute__((aligned(1 << 31))); // expected-error {{requested alignment must be 1073741824 bytes or smaller}}
+int y __attribute__((aligned(1ull << 33))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}}
+int y __attribute__((aligned(1ull << 32)));
 
 // PR26444
 int y __attribute__((aligned(1 << 29)));
Index: clang/test/Sema/alloc-align-attr.c
===================================================================
--- clang/test/Sema/alloc-align-attr.c
+++ clang/test/Sema/alloc-align-attr.c
@@ -2,7 +2,7 @@
 
 // return values
 void test_void_alloc_align(void) __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers}}
-void *test_ptr_alloc_align(unsigned int a) __attribute__((alloc_align(1))); // no-warning
+void *test_ptr_alloc_align(unsigned long long a) __attribute__((alloc_align(1))); // no-warning
 
 int j __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to non-K&R-style functions}}
 void *test_no_params_zero(void) __attribute__((alloc_align(0))); // expected-error {{'alloc_align' attribute parameter 1 is out of bounds}}
@@ -27,5 +27,5 @@
   return test_ptr_alloc_align(15); // expected-warning {{requested alignment is not a power of 2}}
 }
 void *align1073741824() {
-  return test_ptr_alloc_align(2147483648); // expected-warning {{requested alignment must be 1073741824 bytes or smaller; maximum alignment assumed}}
+  return test_ptr_alloc_align(8589934592ull); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
 }
Index: clang/test/CXX/drs/dr6xx.cpp
===================================================================
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -551,10 +551,10 @@
 
 #if __cplusplus >= 201103L
 namespace dr649 { // dr649: yes
-alignas(0x80000000) int n;       // expected-error {{requested alignment}}1
-struct alignas(0x80000000) X {}; // expected-error {{requested alignment}}
+alignas(0x200000000) int n;       // expected-error {{requested alignment}}1
+struct alignas(0x200000000) X {}; // expected-error {{requested alignment}}
 struct Y {
-  int n alignas(0x80000000); // expected-error {{requested alignment}}
+  int n alignas(0x200000000); // expected-error {{requested alignment}}
 };
   struct alignas(256) Z {};
   // This part is superseded by dr2130 and eventually by aligned allocation support.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4082,9 +4082,9 @@
     }
   }
 
-  unsigned MaximumAlignment = Sema::MaximumAlignment;
+  uint64_t MaximumAlignment = Sema::MaximumAlignment;
   if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
-    MaximumAlignment = std::min(MaximumAlignment, 8192u);
+    MaximumAlignment = std::min(MaximumAlignment, uint64_t(8192));
   if (AlignVal > MaximumAlignment) {
     Diag(AttrLoc, diag::err_attribute_aligned_too_great)
         << MaximumAlignment << E->getSourceRange();
Index: clang/lib/Sema/Sema.cpp
===================================================================
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -169,7 +169,7 @@
 } // end namespace clang
 
 const unsigned Sema::MaxAlignmentExponent;
-const unsigned Sema::MaximumAlignment;
+const uint64_t Sema::MaximumAlignment;
 
 Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
            TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -396,8 +396,8 @@
   ///
   /// This is the greatest alignment value supported by load, store, and alloca
   /// instructions, and global values.
-  static const unsigned MaxAlignmentExponent = 30;
-  static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent;
+  static const unsigned MaxAlignmentExponent = 32;
+  static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
 
   typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
   typedef OpaquePtr<TemplateName> TemplateTy;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to