[ubsan] Diagnose invalid uses of builtins (clang)
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 Differential Revision: https://reviews.llvm.org/D34590 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309459 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- docs/UndefinedBehaviorSanitizer.rst 1 addition, 0 deletionsdocs/UndefinedBehaviorSanitizer.rst
- include/clang/Basic/Sanitizers.def 7 additions, 5 deletionsinclude/clang/Basic/Sanitizers.def
- lib/CodeGen/CGBuiltin.cpp 22 additions, 2 deletionslib/CodeGen/CGBuiltin.cpp
- lib/CodeGen/CodeGenFunction.h 12 additions, 0 deletionslib/CodeGen/CodeGenFunction.h
- test/CodeGen/ubsan-builtin-checks.c 44 additions, 0 deletionstest/CodeGen/ubsan-builtin-checks.c
- test/Driver/fsanitize.c 9 additions, 9 deletionstest/Driver/fsanitize.c
Loading
Please register or sign in to comment