[PATCH] D68824: Fix __builtin_assume_aligned with too large values.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 12:28:09 PDT 2019


erichkeane created this revision.
erichkeane added reviewers: lebedev.ri, hfinkel, joey, jdoerfert.
lebedev.ri added a comment.

Thanks, i like it.



================
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2058-2073
+/*
 void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
                                               QualType Ty, SourceLocation Loc,
                                               SourceLocation AssumptionLoc,
                                               unsigned Alignment,
                                               llvm::Value *OffsetValue) {
   llvm::Value *TheCheck;
----------------
Just remove.


================
Comment at: clang/lib/CodeGen/CodeGenFunction.h:2831-2836
+/*
   void EmitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty,
                                SourceLocation Loc, SourceLocation AssumptionLoc,
                                unsigned Alignment,
                                llvm::Value *OffsetValue = nullptr);
+*/
----------------
Just remove.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:6066
              << Arg->getSourceRange();
+    if (Result > (1 << 29ULL))
+      Diag(TheCall->getBeginLoc(), diag::warn_assume_align_too_big)
----------------
`(1ULL << 29ULL)`.
Is there some define for this somwhere, don't like magic numbers.


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.


https://reviews.llvm.org/D68824

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68824.224444.patch
Type: text/x-patch
Size: 7571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191010/33f922fc/attachment-0001.bin>


More information about the cfe-commits mailing list