[PATCH] D13775: Support unknown types in looksLikeFloatCastOverflowDataV1 heuristic.

Maxim Ostapenko via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 08:35:16 PDT 2015


m.ostepenko created this revision.
m.ostepenko added reviewers: filcab, samsonov.
m.ostepenko added subscribers: llvm-commits, ygribov.
m.ostepenko set the repository for this revision to rL LLVM.

Hi,

trying to merge recent sanitizer library into GCC, I've run to the issue: looksLikeFloatCastOverflowDataV1 heuristic failed to work if one of the types is unknown (GCC's _Decimal32 was my case, AFAIK UBSan doesn't support decimal floating types). I see, this is a GCC - specific issue, but since we just make heuristic more precise... . I wonder if it's possible to change heuristic in a such way to support both LLVM and GCC.

Another approach would be to add new entry function (say, __ubsan_handle_float_cast_overflow_old), but I'm not sure what approach is more desirable here.

Thanks.

Repository:
  rL LLVM

http://reviews.llvm.org/D13775

Files:
  lib/ubsan/ubsan_handlers.cc

Index: lib/ubsan/ubsan_handlers.cc
===================================================================
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -314,12 +314,14 @@
                   sizeof(FilenameOrTypeDescriptor));
 
   // Heuristic: For float_cast_overflow, the TypeKind will be either TK_Integer
-  // (0x0) or TK_Float (0x1). Adding both bytes will be 0 or 1 (for BE or LE).
-  // If it were a filename, adding two printable characters will not yield such
-  // a value.
+  // (0x0), TK_Float (0x1) or TK_Unknown (0xff). If both types are known,
+  // adding both bytes will be 0 or 1 (for BE or LE). If it were a filename,
+  // adding two printable characters will not yield such a value. Otherwise,
+  // if one of them is 0xff, this is probably TK_Unknown type descriptor.
   u16 MaybeFromTypeKind =
       FilenameOrTypeDescriptor[0] + FilenameOrTypeDescriptor[1];
-  return MaybeFromTypeKind < 2;
+  return MaybeFromTypeKind < 2 || FilenameOrTypeDescriptor[0] == 0xff ||
+         FilenameOrTypeDescriptor[1] == 0xff;
 }
 
 static void handleFloatCastOverflow(void *DataPtr, ValueHandle From,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13775.37483.patch
Type: text/x-patch
Size: 1130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151015/a8059b62/attachment.bin>


More information about the llvm-commits mailing list