vsk added a comment.

Hi Eli, thanks for your feedback :).

In https://reviews.llvm.org/D30283#702085, @efriedma wrote:

> I'm not sure we actually want to skip these checks for DeclRefExps.  I mean, 
> you can rely on the backend to correctly align a local variable (assuming the 
> stack is correctly aligned), but it's very easy to misalign a global.


I did some experimenting, and think that we can safely skip the alignment check 
for DeclRefExps. Here is what I found:

1. It seems hard to declare a misaligned global. I could not come up with an 
example where this happens. FWIW, I tried playing tricks with the linker but it 
refused to do the wrong thing (`-Wl,-sectalign,__DATA,__common,1` ; 
`-Wl,-order_file,insert_pad_byte_to_misalign_global.order_file`).
2. It's easy to declare a global pointer or reference to misaligned data. UBSan 
already misses this bug: this patch doesn't affect the situation (I filed 
llvm.org/PR32364 to track the issue).

When you said "it's very easy to misalign a global", did you mean that it's 
easy for the compiler to mess up? If so, my thinking is that we should write 
better verifiers, either in our linkers or in LLVM proper. UBSan shouldn't be 
used as a compiler verifier: if it is, end-users will find its diagnostics to 
be less actionable. We shouldn't break user bots because of compiler bugs.

If, OTOH, you meant that it's easy for users to declare misaligned globals, I'd 
appreciate an example.


https://reviews.llvm.org/D30283



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to