diff options
author | Erich Keane <erich.keane@intel.com> | 2019-10-10 21:08:28 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2019-10-10 21:08:28 +0000 |
commit | 31e454c1ecac59273b4864990c8368c3e3fd16b6 (patch) | |
tree | 237e7522efda16adfe890a6f64b6d183416a976f /clang/lib/Sema/SemaChecking.cpp | |
parent | 5e866e411caad4c4e17e7e0c67b06d28451e1bf2 (diff) | |
download | bcm5719-llvm-31e454c1ecac59273b4864990c8368c3e3fd16b6.tar.gz bcm5719-llvm-31e454c1ecac59273b4864990c8368c3e3fd16b6.zip |
Fix __builtin_assume_aligned with too large values.
Code to handle __builtin_assume_aligned was allowing larger values, but
would convert this to unsigned along the way. This patch removes the
EmitAssumeAligned overloads that take unsigned to do away with this
problem.
Additionally, it adds a warning that values greater than 1 <<29 are
ignored by LLVM.
Differential Revision: https://reviews.llvm.org/D68824
llvm-svn: 374450
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 07d3648dc9a..b35d591a7f2 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -6063,6 +6063,16 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) { if (!Result.isPowerOf2()) return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two) << Arg->getSourceRange(); + + // FIXME: this should probably use llvm::Value::MaximumAlignment, however + // doing so results in a linking issue in GCC in a couple of assemblies. + // Alignment calculations can wrap around if it's greater than 2**28. + unsigned MaximumAlignment = + Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192 + : 268435456; + if (Result > MaximumAlignment) + Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great) + << Arg->getSourceRange() << MaximumAlignment; } if (NumArgs > 2) { |