[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 12 14:36:41 PDT 2018


lebedev.ri added a comment.

In https://reviews.llvm.org/D48958#1160848, @vsk wrote:

> In https://reviews.llvm.org/D48958#1160494, @lebedev.ri wrote:
>
> > In https://reviews.llvm.org/D48958#1160479, @vsk wrote:
> >
> > > In https://reviews.llvm.org/D48958#1160435, @lebedev.ri wrote:
> > >
> > > > Thank you for taking a look!
> > > >
> > > > In https://reviews.llvm.org/D48958#1160381, @vsk wrote:
> > > >
> > > > > I have some minor comments but overall I think this is in good shape. It would be great to see some compile-time numbers just to make sure this is tractable. I'm pretty sure -fsanitize=null would fire more often across a codebase than this check, so I don't anticipate a big surprise here.
> > > >
> > > >
> > > > Could you please clarify, which numbers are you looking for, specifically?
> > > >  The time it takes to build llvm stage2 with `-fsanitize=implicit-cast`?
> > > >  Or the time it takes to build llvm stage3 with compiler built with `-fsanitize=implicit-cast`?
> > >
> > >
> > > I had in mind measuring the difference between -fsanitize=undefined and -fsanitize=undefined,implicit-cast, with a stage2 compiler. I think that captures the expected use case: existing ubsan users enabling this new check.
> >
> >
> > FWIW, i'm trying to look into optimizing these new IR patterns right now https://reviews.llvm.org/D49179 https://reviews.llvm.org/D49247.
> >
> > >> (The numbers won't be too representable, whole stage-1 takes ~40 minutes here...)
> > > 
> > > Ah I see, I'll run a few builds and take a stab at it, then.
> >
> > Yes, please, thank you!
>
>
> The stage2 build traps before it finishes:
>
>   FAILED: lib/IR/AttributesCompatFunc.inc.tmp
>   cd /Users/vsk/src/builds/llvm.org-lldbsan-stage2-R/tools/clang/stage2-bins && /Users/vsk/src/builds/llvm.org-lldbsan-stage2-R/tools/clang/stage2-bins/bin/llvm-tblgen -gen-attrs -I /Users/vsk/src/llvm.org-lldbsan/llvm/lib/IR -I /Users/vsk/src/llvm.org-lldbsan/llvm/include /Users/vsk/src/llvm.org-lldbsan/llvm/lib/IR/AttributesCompatFunc.td -o lib/IR/AttributesCompatFunc.inc.tmp -d lib/IR/AttributesCompatFunc.inc.d
>   /Users/vsk/src/llvm.org-lldbsan/llvm/include/llvm/ADT/DenseMap.h:732:66: runtime error: implicit cast from type 'uint64_t' (aka 'unsigned long long') of value 4294967296 (64-bit, unsigned) to type 'unsigned int' changed the value to 0 (32-bit, unsigned)
>   /bin/sh: line 1: 96848 Abort trap: 6
>
>
> This looks like a false positive to me. It's complaining about `static_cast<unsigned>(NextPowerOf2(...))`, but the static_cast is explicit.


Good to know, so the stack-based logic for `ExplicitCastExpr` detection needs further tests/refinements..


Repository:
  rC Clang

https://reviews.llvm.org/D48958





More information about the cfe-commits mailing list