[compiler-rt] [llvm] [flang] [clang-tools-extra] [clang] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 19:56:10 PST 2023


================
@@ -322,6 +322,66 @@ static Attr *handleUnlikely(Sema &S, Stmt *St, const ParsedAttr &A,
   return ::new (S.Context) UnlikelyAttr(S.Context, A);
 }
 
+CodeAlignAttr *Sema::BuildCodeAlignAttr(const AttributeCommonInfo &CI,
+                                        Expr *E) {
+  if (!E->isValueDependent()) {
+    llvm::APSInt ArgVal;
+    ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
+    if (Res.isInvalid())
+      return nullptr;
+    E = Res.get();
+
+    // This attribute requires an integer argument which is a constant power of
+    // two between 1 and 4096 inclusive.
+    int AlignValue = ArgVal.getSExtValue();
----------------
smanna12 wrote:

> I think SExt makes sense, but this would cause a problem for `9223372036854775808` (int64-max +1).

Yes.

@erichkeane,  I have updated patch to avoid this kind of problem with commit https://github.com/llvm/llvm-project/pull/70762/commits/088767463be990eb8af4e62a6c66cf4ba06613c3. 




https://github.com/llvm/llvm-project/pull/70762


More information about the llvm-commits mailing list