[clang] 1624cba - Partially revert "[IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant"
Roman Lebedev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 23 12:31:28 PST 2020
Author: Roman Lebedev
Date: 2020-01-23T23:30:42+03:00
New Revision: 1624cba7824967c15ac36d9fdd41bb9878463dbe
URL: https://github.com/llvm/llvm-project/commit/1624cba7824967c15ac36d9fdd41bb9878463dbe
DIFF: https://github.com/llvm/llvm-project/commit/1624cba7824967c15ac36d9fdd41bb9878463dbe.diff
LOG: Partially revert "[IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant"
Apparently makes bots angry.
This reverts commit d096f8d306b2b16a25f65ffb70849ca7963a0dac.
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 92d964d6603d..fae1ade80ca9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -372,15 +372,6 @@ class Sema final {
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;
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1539f3375c41..1f361569e09d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5373,9 +5373,11 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) {
return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
<< Arg->getSourceRange();
- if (Result > Sema::MaximumAlignment)
+ // Alignment calculations can wrap around if it's greater than 2**29.
+ unsigned MaximumAlignment = 536870912;
+ if (Result > MaximumAlignment)
Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
- << Arg->getSourceRange() << Sema::MaximumAlignment;
+ << Arg->getSourceRange() << MaximumAlignment;
}
if (NumArgs > 2) {
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b404b45fec59..8aff975b8f2d 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3810,9 +3810,13 @@ void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
}
}
- if (AlignVal > Sema::MaximumAlignment) {
+ // 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)
- << Sema::MaximumAlignment << E->getSourceRange();
+ << MaxValidAlignment << E->getSourceRange();
return;
}
More information about the cfe-commits
mailing list