[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 15 10:26:10 PST 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: ABataev, craig.topper, vsk, rsmith, rnk, Sanitizers, erichkeane, filcab, rjmccall.
lebedev.ri added a project: Sanitizers.
lebedev.ri added a dependency: D54588: [llvm][IRBuilder] Introspection for CreateAlignmentAssumption*() functions.

UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
P1007R3: std::assume_aligned <https://wg21.link/p1007r3> / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:

  We propose to add this functionality via a library function instead of a core language attribute.
  ...
  If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour.

This differential teaches clang to sanitize all the various variants of this assume-aligned attribute.

Requires https://reviews.llvm.org/D54588 for LLVM IRBuilder changes.


Repository:
  rC Clang

https://reviews.llvm.org/D54589

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  test/CodeGen/catch-alignment-assumption-blacklist.c
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  test/CodeGen/catch-alignment-assumption-openmp.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54589.174237.patch
Type: text/x-patch
Size: 53931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181115/4e8ad75d/attachment-0001.bin>


More information about the cfe-commits mailing list