From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27080 invoked by alias); 23 May 2014 14:56:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27071 invoked by uid 89); 23 May 2014 14:56:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f179.google.com Received: from mail-vc0-f179.google.com (HELO mail-vc0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 23 May 2014 14:56:02 +0000 Received: by mail-vc0-f179.google.com with SMTP id im17so6397258vcb.10 for ; Fri, 23 May 2014 07:55:59 -0700 (PDT) X-Received: by 10.52.147.170 with SMTP id tl10mr3994797vdb.14.1400856959756; Fri, 23 May 2014 07:55:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.144.3 with HTTP; Fri, 23 May 2014 07:55:39 -0700 (PDT) In-Reply-To: References: <20140523141900.GD17600@redhat.com> <20140523142839.GU10386@tucnak.redhat.com> From: Konstantin Serebryany Date: Fri, 23 May 2014 14:56:00 -0000 Message-ID: Subject: Re: [PATCH] Implement -fsanitize=float-cast-overflow (take 3) To: Jakub Jelinek Cc: Marek Polacek , GCC Patches , "Joseph S. Myers" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg02022.txt.bz2 On Fri, May 23, 2014 at 6:35 PM, Konstantin Serebryany wrote: > On Fri, May 23, 2014 at 6:28 PM, Jakub Jelinek wrote: >> On Fri, May 23, 2014 at 04:19:00PM +0200, Marek Polacek wrote: >>> This is the latest patch for -fsanitize=float-cast-overflow. Since last >>> version it: >>> - adds tons of tests written by Jakub; >>> - patches libubsan so it can handle 96-bit floating-point types >>> (that is, long double and __float80 in -m32 mode); >> >> CCing Kostya on this one liner, which has been posted to llvm-commits, >> but nothing has been done yet. I'm approving this anyway, I don't see >> anything controversial on it and clang fails without that change the same >> (supposedly insufficient test coverage on the compiler-rt side). > > ubsan is not my domain, but since the patch is so simple let me try to > handle it. http://llvm.org/viewvc/llvm-project?view=revision&revision=209516 > >> >>> - includes a hack for printing __float{80,128}/_Decimal* types in >>> libubsan. Since libubsan handles only float/double/long double >>> floating-point types, we use TK_Unknown for other types, meaning >>> that libubsan prints "" instead of the value. >> >> I think this is for now good, while in theory I can imagine not very long >> code to print _Decimal* to string (convert to binary integer format if >> in the densely packed format (hey, ppc*), print __int128 significand >> (or do 2x wide long long division/modulo) into string using snprintf, >> take care of exponent and sign and putting in decimal dot), it is not high >> prio for me, and for __float128 you can hardly avoid libquadmath or >> something similarly large, unless you want to print it as C99 hexadecimal >> float (that would be again pretty easy). >> >>> Regtested/bootstrapped on x86_64-linux. Couldn't test ppc64, as >>> libsanitizer currently doesn't build on this architecture. >>> >>> Ok for trunk? >>> >>> 2014-05-23 Marek Polacek >>> Jakub Jelinek >>> >>> * builtins.def: Change SANITIZE_FLOAT_DIVIDE to SANITIZE_NONDEFAULT. >>> * gcc.c (sanitize_spec_function): Likewise. >>> * convert.c (convert_to_integer): Include "ubsan.h". Add >>> floating-point to integer instrumentation. >>> * doc/invoke.texi: Document -fsanitize=float-cast-overflow. >>> * flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_CAST and >>> SANITIZE_NONDEFAULT. >>> * opts.c (common_handle_option): Handle -fsanitize=float-cast-overflow. >>> * sanitizer.def (BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW, >>> BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW_ABORT): Add. >>> * ubsan.c: Include "realmpfr.h" and "dfp.h". >>> (get_ubsan_type_info_for_type): Handle REAL_TYPEs. >>> (ubsan_type_descriptor): Set tkind to 0xffff for types other than >>> float/double/long double. >>> (ubsan_instrument_float_cast): New function. >>> * ubsan.h (ubsan_instrument_float_cast): Declare. >>> testsuite/ >>> * c-c++-common/ubsan/float-cast-overflow-1.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-10.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-2.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-3.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-4.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-5.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-6.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-7.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-7.h: New file. >>> * c-c++-common/ubsan/float-cast-overflow-8.c: New test. >>> * c-c++-common/ubsan/float-cast-overflow-9.c: New test. >>> * c-c++-common/ubsan/float-cast.h: New file. >>> * g++.dg/ubsan/float-cast-overflow-bf.C: New test. >>> * gcc.dg/ubsan/float-cast-overflow-bf.c: New test. >>> libsanitizer/ >>> * ubsan/ubsan_value.cc (getFloatValue): Handle 96-bit >>> floating-point types. >> >> Ok, thanks. >> >> Jakub