[PATCH] D25295: [ubsan] Handle undef values in the integer overflow diagnostic

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 16:16:25 PDT 2016


vsk created this revision.
vsk added a reviewer: rsmith.
vsk added a subscriber: llvm-commits.
vsk added a dependency: D25294: [ubsan] Un-templatize handleIntegerOverflowImpl (NFC).
Herald added a subscriber: kubabrecka.

The compiler may optimize away the values passed into ubsan's integer
overflow handlers. This can lead to confusing reports. E.g, the runtime
reports overflows in nonsensical expressions such as "0 + 0":

  struct Undef { int I; }
  
  int getUndefInt() { return Undef().I; }
  
  int main() { return getUndefInt() + getUndefInt(); }

Improve the situation by checking for an actual overflow in the handler.
If we can't reproduce the overflow, emit an explanation to the user.

Depends on https://reviews.llvm.org/D25294.


https://reviews.llvm.org/D25295

Files:
  lib/ubsan/ubsan_diag.h
  lib/ubsan/ubsan_handlers.cc
  test/ubsan/TestCases/Integer/Inputs/undef-overflow.bc
  test/ubsan/TestCases/Integer/Inputs/undef-overflow.input.ll
  test/ubsan/TestCases/Integer/undef-overflow.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25295.73707.patch
Type: text/x-patch
Size: 7825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161005/77e5989a/attachment.bin>


More information about the llvm-commits mailing list