[PATCH] D58236: Make address space conversions a bit stricter.

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 03:36:22 PST 2019


Anastasia added a comment.

In D58236#1414069 <https://reviews.llvm.org/D58236#1414069>, @efriedma wrote:

> > I think trying to reject code that is doing something dangerous is a good thing!
>
> Refusing to compile code which is suspicious, but not forbidden by the specification, will likely cause compatibility issues; there are legitimate reasons to use casts which look weird.


The spec dioesn't allow these conversions either, it just simply doesn't cover this corner case at all. I don't think we are changing anything in terms of compatibility. If you have any examples of such casts that can be legitimate I would like to understand them better. What I have seen so far were the examples where `addrspacecast` was lost in IR for the memory segments translation and therefore wrong memory areas were accessed.

> I'm not against adding some sort of address space suspicious cast warning to catch cases where we think the user meant to do something else.

I simply don't see how these conversions can be useful and some are definitely indirectly forbidden (there is no precise wording however). There are other ways to perform such conversions differently (by being more explicit) where correct IR can be then generated with `addrspacecast`. I don't think we are loosing anything in terms of functionality.

> But that's a separate issue, and it needs a proper cost-benefit analysis, including an analysis of the false-positive rate on existing code.

Do you have any suggestions how to do this in practice with such rare corner case?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58236/new/

https://reviews.llvm.org/D58236





More information about the cfe-commits mailing list