[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL297298: [ubsan] Detect UB loads from bitfields (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D30423?vs=90869&id=91041#toc Repository: rL LLVM https://reviews.llvm.org/D304

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. In https://reviews.llvm.org/D30423#695608, @filcab wrote: > LGTM since my issue is only an issue on ObjC platforms and it seems those are > the semantics it should have there. Thanks for the review. > P.S: If it documented that the only possible values for BOOL are YES an

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-08 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment. LGTM since my issue is only an issue on ObjC platforms and it seems those are the semantics it should have there. Comment at: test/CodeGenObjC/ubsan-bool.m:26 + // OBJC: [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize + // OBJC: call void @__ubsa

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments. Comment at: test/CodeGenObjC/ubsan-bool.m:26 + // OBJC: [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize + // OBJC: call void @__ubsan_handle_load_invalid_value + filcab wrote: > jroelofs wrote: > > vsk wrote: > > > jroelofs wrote

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-08 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added inline comments. Comment at: test/CodeGenObjC/ubsan-bool.m:26 + // OBJC: [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize + // OBJC: call void @__ubsan_handle_load_invalid_value + jroelofs wrote: > vsk wrote: > > jroelofs wrote: > > > vsk wrote

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-07 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision. jroelofs added a comment. This revision is now accepted and ready to land. LGTM Comment at: test/CodeGenObjC/ubsan-bool.m:26 + // OBJC: [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize + // OBJC: call void @__ubsan_handle_load_invalid_valu

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments. Comment at: test/CodeGenCXX/ubsan-bitfields.cpp:21 + // CHECK: call void @__ubsan_handle_load_invalid_value + return s->e1; +} vsk wrote: > arphaman wrote: > > Can we avoid the check if the bitfield is 2 bits wide? > I don't think so,

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 90869. vsk added a comment. - Improve objc test coverage per Jon's suggestions. https://reviews.llvm.org/D30423 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/ubsan-bitfields.cpp test/CodeGenObjC/u

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. In https://reviews.llvm.org/D30423#694003, @jroelofs wrote: > I think this might miss loads from bitfield ivars. I'll add a test that shows that this case is covered. > Also, what about the conversion that happens for properties whose backing > ivar is a bitfield? (or doe

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-06 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment. I think this might miss loads from bitfield ivars. Also, what about the conversion that happens for properties whose backing ivar is a bitfield? (or does that happen in the runtime? can't remember) Comment at: test/CodeGenObjC/ubsan-bool.m:25 + // O

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-06 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. Thanks for the feedback! Comment at: test/CodeGenCXX/ubsan-bitfields.cpp:21 + // CHECK: call void @__ubsan_handle_load_invalid_value + return s->e1; +} arphaman wrote: > Can we avoid the check if the bitfield is 2 bits wide? I don't think

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-03-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments. Comment at: test/CodeGenCXX/ubsan-bitfields.cpp:21 + // CHECK: call void @__ubsan_handle_load_invalid_value + return s->e1; +} Can we avoid the check if the bitfield is 2 bits wide? Comment at: test/CodeGenObjC

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-02-27 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision. We frequently run into user bugs caused by UB loads of out-of-range values from enum / BOOL bitfields. Teach UBSan to diagnose the issue. https://reviews.llvm.org/D30423 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test