[PATCH] D19668: [ubsan] Minimize size of data for type_mismatch
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 08:46:52 PDT 2016
Hi Ben,
No need to OR with 0x80. If we have two bits set in the first two
bytes, then we know it's (at least) V2 (we can set Alignment to 1 when
we've been given 0, and have one bit from there).
I was probing to know if it's an actual use-case people have been
using UBSan with (which makes it very desirable), or if we simply do
not care that much. If people have seen this in the wild (I'm ok with
someone saying they've been using it that way internally, too), then
it's obvious we want to try to keep compatibility.
Thank you,
Filipe
On Thu, Apr 28, 2016 at 7:23 PM, Ben Craig <ben.craig at codeaurora.org> wrote:
> bcraig added a subscriber: bcraig.
> bcraig added a comment.
>
> If we want to be able to reuse old objects, then you could put a Version member between Alignment and TypeCheckKind.
>
> In the old version, alignment always stored a power of two. That means that only a single bit was set in the four bytes available. If you put something with more than one bit in any one of those bytes, then we can tell that it isn't a version zero struct.
>
> //exposition only
> #define VERSION_ZERO 0x00
> #define VERSION_ONE 0x80 | 0x01
> #define VERSION_TWO 0x80 | 0x02
>
> struct TypeMismatchData {
> SourceLocation Loc;
> const TypeDescriptor &Type;
> unsigned char Alignment;
> unsigned char Version = VERSION_ONE;
> unsigned char TypeCheckKind;
> };
>
>
> http://reviews.llvm.org/D19668
>
>
>
More information about the llvm-commits
mailing list