This revision was automatically updated to reflect the committed changes. Closed by commit rGd096f8d306b2: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant (authored by lebedev.ri).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72998/new/ https://reviews.llvm.org/D72998 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDeclAttr.cpp llvm/lib/IR/Attributes.cpp
Index: llvm/lib/IR/Attributes.cpp =================================================================== --- llvm/lib/IR/Attributes.cpp +++ llvm/lib/IR/Attributes.cpp @@ -143,7 +143,7 @@ } Attribute Attribute::getWithAlignment(LLVMContext &Context, Align A) { - assert(A <= 0x40000000 && "Alignment too large."); + assert(A <= llvm::Value::MaximumAlignment && "Alignment too large."); return get(Context, Alignment, A.value()); } @@ -1525,7 +1525,7 @@ if (!Align) return *this; - assert(*Align <= 0x40000000 && "Alignment too large."); + assert(*Align <= llvm::Value::MaximumAlignment && "Alignment too large."); Attrs[Attribute::Alignment] = true; Alignment = Align; Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -1626,11 +1626,9 @@ return; } - // Alignment calculations can wrap around if it's greater than 2**29. - unsigned MaximumAlignment = 536870912; - if (I > MaximumAlignment) + if (I > Sema::MaximumAlignment) Diag(CI.getLoc(), diag::warn_assume_aligned_too_great) - << CI.getRange() << MaximumAlignment; + << CI.getRange() << Sema::MaximumAlignment; } if (OE) { @@ -3815,13 +3813,9 @@ } } - // Alignment calculations can wrap around if it's greater than 2**28. - unsigned MaxValidAlignment = - Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192 - : 268435456; - if (AlignVal > MaxValidAlignment) { - Diag(AttrLoc, diag::err_attribute_aligned_too_great) << MaxValidAlignment - << E->getSourceRange(); + if (AlignVal > Sema::MaximumAlignment) { + Diag(AttrLoc, diag::err_attribute_aligned_too_great) + << Sema::MaximumAlignment << E->getSourceRange(); return; } Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -3665,11 +3665,9 @@ return; } - // Alignment calculations can wrap around if it's greater than 2**29. - unsigned MaximumAlignment = 536870912; - if (I > MaximumAlignment) + if (I > Sema::MaximumAlignment) Diag(Arg->getExprLoc(), diag::warn_assume_aligned_too_great) - << Arg->getSourceRange() << MaximumAlignment; + << Arg->getSourceRange() << Sema::MaximumAlignment; } } } @@ -5394,11 +5392,9 @@ return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two) << Arg->getSourceRange(); - // Alignment calculations can wrap around if it's greater than 2**29. - unsigned MaximumAlignment = 536870912; - if (Result > MaximumAlignment) + if (Result > Sema::MaximumAlignment) Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great) - << Arg->getSourceRange() << MaximumAlignment; + << Arg->getSourceRange() << Sema::MaximumAlignment; } if (NumArgs > 2) { Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -372,6 +372,15 @@ QualType ResultTy, ArrayRef<QualType> Args); + /// The maximum alignment, same as in llvm::Value. We duplicate them here + /// because that allows us not to duplicate the constants in clang code, + /// which we must to since we can't directly use the llvm constants. + /// + /// This is the greatest alignment value supported by load, store, and alloca + /// instructions, and global values. + static const unsigned MaxAlignmentExponent = 29; + static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent; + public: 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