This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Add SourceLocations for float_cast_overflow data.
ClosedPublic

Authored by filcab on Aug 5 2015, 11:51 PM.

Details

Summary

Compiler-rt part of http://reviews.llvm.org/D11757
I ended up making UBSan work with both the old version and the new
version of the float_cast_overflow data (instead of just erroring with
the previous version). The old version will try to symbolize its caller.

Now we compile the float_cast_overflow tests without -g, and make sure
we have the source file+line+column.

If you think I'm trying too hard to make sure we can still use both
versions, let me know.

Diff Detail

Repository
rL LLVM

Event Timeline

filcab updated this revision to Diff 31428.Aug 5 2015, 11:51 PM
filcab retitled this revision from to [compiler-rt] Add SourceLocations for float_cast_overflow data..
filcab updated this object.
filcab added reviewers: samsonov, rsmith.
filcab added a subscriber: llvm-commits.
filcab updated this revision to Diff 31523.Aug 7 2015, 9:30 AM

Remove undefined behavior (unless I misread the standard) :-)

We could use __builtin_memcpy to avoid the call and get a simple "mov" instruction (on x86), but I'm not sure if that's available for all compilers we support.
Opinions?

samsonov added inline comments.Aug 7 2015, 5:13 PM
lib/ubsan/ubsan_handlers.h
101 ↗(On Diff #31523)

with older compilers.

114 ↗(On Diff #31523)

just use void* Data (or u8* Data) here, and reinterpret_cast it in the function? That would help in looksLikeFloatCastOverflowDataV1

test/ubsan/TestCases/Float/cast-overflow.cpp
89 ↗(On Diff #31523)

use [[@LINE+1]] here and below to reference line number.

filcab updated this revision to Diff 31574.Aug 7 2015, 11:21 PM
filcab marked 3 inline comments as done.

Addressed Alexey's comments.

Addressed Alexey's comments. Had to cheat on the "__int128 not supported" case, but I think the current test is not bad.
Also simplified the return expression on looksLikeFloatCastOverflowDataV1.

That would help in looksLikeFloatCastOverflowDataV1

I'm not sure what you mean here.

samsonov accepted this revision.Aug 10 2015, 1:37 PM
samsonov edited edge metadata.

LGTM. Thanks for doing this!

lib/ubsan/ubsan_handlers.cc
297 ↗(On Diff #31574)

Why not reinterpret_cast<u8*>(Data)?

lib/ubsan/ubsan_handlers.h
114 ↗(On Diff #31574)

Please add a comment that "void *Data" should be either FloatCastOverflowData* or FloatCastOverflowDataV2*.

This revision is now accepted and ready to land.Aug 10 2015, 1:37 PM

Will update on the repo. Thanks for the review.

lib/ubsan/ubsan_handlers.cc
297 ↗(On Diff #31574)

It would actually be: *reinterpret_cast<u8**>(Data), which would dereferrence a pointer to char* OR a pointer to TypeDescriptor, which AFAICT, would technically be UB in one of those cases, due to dereferencing a pointer to A as a pointer to B (where A is TypeDescriptor, and B is a char *). (the first version of the patch had this, and this shouldn't be a problem, but still... technically UB as far as I can tell).

samsonov added inline comments.Aug 10 2015, 2:18 PM
lib/ubsan/ubsan_handlers.cc
297 ↗(On Diff #31574)

I see, thanks for the explanation!

This revision was automatically updated to reflect the committed changes.