[PATCH] D79234: [ValueTracking] Fix computeKnownBits() with bitwidth-changing ptrtoint

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 15 13:37:30 PDT 2020


nikic added a comment.

In D79234#2023197 <https://reviews.llvm.org/D79234#2023197>, @efriedma wrote:

> Historically, we allowed IR without a datalayout, so we didn't actually know what the pointer width would be when the IR was eventually compiled.  Given that, allowing arbitrary casts was the least-bad alternative: otherwise, we wouldn't be able to verify a module.
>
> Now that datalayout is required, we could maybe restrict the legal ptrtoint casts?  Not sure what we would do about ptrtoint constant expressions; constant expressions that don't reference globals aren't associated with a particular module.


Thanks for the context! Would anything speak against making the validity of constant expressions dependent on which module they are used in? That is, the same constant expression could be valid in one module and invalid in another, depending on data layout. As the validator works by recursively checking constants referenced in the module, I think that should work.

I may look into adding this requirement as a longer term change. I'd prefer to land this patch in the meantime though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79234





More information about the llvm-commits mailing list