Skip to content

Commit 1624cba

Browse files
committed
Partially revert "[IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant"
Apparently makes bots angry. This reverts commit d096f8d.
1 parent fa2fc81 commit 1624cba

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,6 @@ class Sema final {
372372
QualType ResultTy,
373373
ArrayRef<QualType> Args);
374374

375-
/// The maximum alignment, same as in llvm::Value. We duplicate them here
376-
/// because that allows us not to duplicate the constants in clang code,
377-
/// which we must to since we can't directly use the llvm constants.
378-
///
379-
/// This is the greatest alignment value supported by load, store, and alloca
380-
/// instructions, and global values.
381-
static const unsigned MaxAlignmentExponent = 29;
382-
static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent;
383-
384375
public:
385376
typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
386377
typedef OpaquePtr<TemplateName> TemplateTy;

clang/lib/Sema/SemaChecking.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5373,9 +5373,11 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) {
53735373
return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
53745374
<< Arg->getSourceRange();
53755375

5376-
if (Result > Sema::MaximumAlignment)
5376+
// Alignment calculations can wrap around if it's greater than 2**29.
5377+
unsigned MaximumAlignment = 536870912;
5378+
if (Result > MaximumAlignment)
53775379
Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
5378-
<< Arg->getSourceRange() << Sema::MaximumAlignment;
5380+
<< Arg->getSourceRange() << MaximumAlignment;
53795381
}
53805382

53815383
if (NumArgs > 2) {

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,9 +3810,13 @@ void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
38103810
}
38113811
}
38123812

3813-
if (AlignVal > Sema::MaximumAlignment) {
3813+
// Alignment calculations can wrap around if it's greater than 2**28.
3814+
unsigned MaxValidAlignment =
3815+
Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
3816+
: 268435456;
3817+
if (AlignVal > MaxValidAlignment) {
38143818
Diag(AttrLoc, diag::err_attribute_aligned_too_great)
3815-
<< Sema::MaximumAlignment << E->getSourceRange();
3819+
<< MaxValidAlignment << E->getSourceRange();
38163820
return;
38173821
}
38183822

0 commit comments

Comments
 (0)