[PATCH] D34590: [ubsan] Diagnose invalid uses of builtins (clang)

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 23 20:36:44 PDT 2017


vsk created this revision.

On some targets, passing zero to the clz() or ctz() builtins has
undefined behavior. I ran into this issue while debugging UB in
__hash_table from libcxx: the bug I was seeing manifested itself
differently under -O0 vs -Os, due to a UB call to clz() (see:
libcxx/r304617).

This patch introduces a check which can detect UB calls to builtins.

llvm.org/PR26979


https://reviews.llvm.org/D34590

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-builtin-checks.c
  test/Driver/fsanitize.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34590.103827.patch
Type: text/x-patch
Size: 16171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170624/5ab0b00b/attachment.bin>


More information about the cfe-commits mailing list