craig.topper updated this revision to Diff 372331.
craig.topper added a comment.

Add comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109714/new/

https://reviews.llvm.org/D109714

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/ext-int.c
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/SemaCXX/ext-int.cpp

Index: clang/test/SemaCXX/ext-int.cpp
===================================================================
--- clang/test/SemaCXX/ext-int.cpp
+++ clang/test/SemaCXX/ext-int.cpp
@@ -29,8 +29,8 @@
   constexpr _ExtInt(7) o = 33;
 
   // Check LLVM imposed max size.
-  _ExtInt(0xFFFFFFFFFF) p; // expected-error {{signed _ExtInt of bit sizes greater than 16777215 not supported}}
-  unsigned _ExtInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 16777215 not supported}}
+  _ExtInt(8388609) p; // expected-error {{signed _ExtInt of bit sizes greater than 8388608 not supported}}
+  unsigned _ExtInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 8388608 not supported}}
 
 // Ensure template params are instantiated correctly.
   // expected-error@5{{signed _ExtInt must have a bit size of at least 2}}
Index: clang/test/CodeGenCXX/ext-int.cpp
===================================================================
--- clang/test/CodeGenCXX/ext-int.cpp
+++ clang/test/CodeGenCXX/ext-int.cpp
@@ -223,23 +223,23 @@
   // WIN: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]]
   // WIN: store i129 %[[LOADV4]], i129*
 
-  _ExtInt(16777200) E = __builtin_va_arg(args, _ExtInt(16777200));
+  _ExtInt(8388600) E = __builtin_va_arg(args, _ExtInt(8388600));
   // LIN: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD5]], i32 0, i32 2
   // LIN: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]]
-  // LIN: %[[BC5:.+]] = bitcast i8* %[[OFA5]] to i16777200*
-  // LIN: %[[OFANEXT5:.+]] = getelementptr i8, i8* %[[OFA5]], i32 2097152
+  // LIN: %[[BC5:.+]] = bitcast i8* %[[OFA5]] to i8388600*
+  // LIN: %[[OFANEXT5:.+]] = getelementptr i8, i8* %[[OFA5]], i32 1048576
   // LIN: store i8* %[[OFANEXT5]], i8** %[[OFA_P5]]
-  // LIN: %[[LOAD5:.+]] = load i16777200, i16777200* %[[BC5]]
-  // LIN: store i16777200 %[[LOAD5]], i16777200*
+  // LIN: %[[LOAD5:.+]] = load i8388600, i8388600* %[[BC5]]
+  // LIN: store i8388600 %[[LOAD5]], i8388600*
 
   // WIN: %[[CUR5:.+]] = load i8*, i8** %[[ARGS]]
   // WIN: %[[NEXT5:.+]] = getelementptr inbounds i8, i8* %[[CUR5]], i64 8
   // WIN: store i8* %[[NEXT5]], i8** %[[ARGS]]
-  // WIN: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i16777200**
-  // WIN: %[[LOADP5:.+]] = load i16777200*, i16777200** %[[BC5]]
-  // WIN: %[[LOADV5:.+]] = load i16777200, i16777200* %[[LOADP5]]
-  // WIN: store i16777200 %[[LOADV5]], i16777200*
+  // WIN: %[[BC5:.+]] = bitcast i8* %[[CUR5]] to i8388600**
+  // WIN: %[[LOADP5:.+]] = load i8388600*, i8388600** %[[BC5]]
+  // WIN: %[[LOADV5:.+]] = load i8388600, i8388600* %[[LOADP5]]
+  // WIN: store i8388600 %[[LOADV5]], i8388600*
 
   __builtin_va_end(args);
   // LIN: %[[ENDAD:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
@@ -295,7 +295,7 @@
 
 struct S {
   _ExtInt(17) A;
-  _ExtInt(16777200) B;
+  _ExtInt(8388600) B;
   _ExtInt(17) C;
 };
 
@@ -308,7 +308,7 @@
   auto B = __builtin_offsetof(S,B);
   // CHECK: store i64 8, i64* %{{.+}}
   auto C = __builtin_offsetof(S,C);
-  // CHECK: store i64 2097160, i64* %{{.+}}
+  // CHECK: store i64 1048584, i64* %{{.+}}
 }
 
 
Index: clang/test/CodeGen/ext-int.c
===================================================================
--- clang/test/CodeGen/ext-int.c
+++ clang/test/CodeGen/ext-int.c
@@ -28,7 +28,7 @@
 
 struct S {
   _ExtInt(17) A;
-  _ExtInt(16777200) B;
+  _ExtInt(8388600) B;
   _ExtInt(17) C;
 };
 
@@ -41,9 +41,9 @@
   // LIN32: store i32 4, i32* %{{.+}}
   // WINCHECK32: store i32 8, i32* %{{.+}}
   int C = __builtin_offsetof(struct S,C);
-  // CHECK64: store i32 2097160, i32* %{{.+}}
-  // LIN32: store i32 2097156, i32* %{{.+}}
-  // WIN32: store i32 2097160, i32* %{{.+}}
+  // CHECK64: store i32 1048584, i32* %{{.+}}
+  // LIN32: store i32 1048580, i32* %{{.+}}
+  // WIN32: store i32 1048584, i32* %{{.+}}
 }
 
 void Size1ExtIntParam(unsigned _ExtInt(1) A) {
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2269,9 +2269,13 @@
     return QualType();
   }
 
-  if (NumBits > llvm::IntegerType::MAX_INT_BITS) {
-    Diag(Loc, diag::err_ext_int_max_size) << IsUnsigned
-                                          << llvm::IntegerType::MAX_INT_BITS;
+  // For types that aren't natively supported, SelectionDAG type legalization
+  // needs to create a power of 2 integer type with at least as many bit as the
+  // ExtInt. This places an effective upper limit as the largest power of 2 less
+  // than MAX_INT_BITS.
+  int MaxBits = PowerOf2Floor(llvm::IntegerType::MAX_INT_BITS);
+  if (NumBits > MaxBits) {
+    Diag(Loc, diag::err_ext_int_max_size) << IsUnsigned << MaxBits;
     return QualType();
   }
 
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -56,7 +56,8 @@
 Non-comprehensive list of changes in this release
 -------------------------------------------------
 
-- ...
+- Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
+  Motivation for this was discussed in PR51829.
 
 New Compiler Flags
 ------------------
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to