[PATCH] D64128: [CodeGen] Generate llvm.ptrmask instead of inttoptr(and(ptrtoint, C)) if possible.
JF Bastien via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 3 15:37:56 PDT 2019
jfb added a comment.
I'm not sure I understand all the implications, and why that would / wouldn't be valid.
Should this be an builtin that can be called from C++ directly?
================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2034
+ (AllOnes << llvm::Log2_64(DL.getPointerABIAlignment(static_cast<unsigned>(
+ CE->getSubExpr()->getType()->getPointeeType().getAddressSpace()))));
+ if (!BO->getRHS()->isIntegerConstantExpr(CV, Ctx) ||
----------------
This assumes pointers are max 64 bits :)
It seems better to shift `CV` up by `bit_per_byte*sizeof(void*) - max_pointer_size`, and then down to remove alignment, and finally checking that it's zero?
Which leads me to wonder: should we ever diagnose "bad" pointer masks?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64128/new/
https://reviews.llvm.org/D64128
More information about the cfe-commits
mailing list