[PATCH] D32456: [ubsan] Make the alignment check work with some extern decls (PR32630)

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 25 14:03:31 PDT 2017


vsk added a comment.

In https://reviews.llvm.org/D32456#737273, @efriedma wrote:

> Err, that's not what I meant...
>
> If the alignment of a global in LLVM IR is "zero", it doesn't really mean zero.  It means "guess the alignment I want based on the specified type of the global".  And that's not a game we ever want to play when generating IR from clang.


The alternative mentioned in PR32630 is to decrease the alignment of the global when -fsanitize=alignment is enabled. Is this less risky than not specifying the alignment at all? I assumed that it was not.

Hm, giving this more thought I'm not happy with how fragile this patch seems. Changing the way we set alignment to hack around constant folding doesn't seem great. And this patch does not interact properly with extern definitions which have '__attribute__((aligned(N)))' set.


https://reviews.llvm.org/D32456





More information about the cfe-commits mailing list