[PATCH] D59065: Add ptrmask intrinsic

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 13:48:56 PDT 2019


jdoerfert added a comment.

What happens if I use an integer type bigger than the native pointer width? Or smaller?



================
Comment at: llvm/docs/LangRef.rst:16396
+The ``llvm.ptrmask`` intrinsic can be used to mask out bits of a pointer that
+must be zero when accessing it, because of ABI alignment requirements or
+a restriction of the meaningful bits through the data layout. This can be used
----------------
Can you split the sentences? Maybe also make them active. To see what I would like I tried to rewrite it myself. No need to take it though!

The ``llvm.ptrmask`` intrinsic mask out bits of the pointer that are set in the mask.
This allows stripping data from tagged pointers without ever converting them to an integer (ptrtoint/inttoptr). As a consequence, we can preserve more information to facilitate alias analysis and underlying object detection. The masked out bits cannot be meaningful bits as defined by the ABI and data layout. Only bits like required alignment bits shall be masked out.


================
Comment at: llvm/docs/LangRef.rst:16404
+
+The mask argument must only zero out bits that are not part of the relevant bits
+of the pointer. Passing masks that zero out relevant bits of the pointer
----------------
Start with the semantic, e.g., the bitwise AND sentence below.


================
Comment at: llvm/docs/LangRef.rst:16409
+required by the ABI alignment requirement. The intrinsic will get lowered to a
+bitwise and instruction or equivalent. Both the returned pointer and the first
+argument point to the same underlying object.
----------------
I'm missing something like the following:

"The semantic of the intrinsic is equivalent to a bitwise AND operation of the two operands."

That could also replace the lowering part (which does not specify much anyway).

And the last sentence is also problematic, now that you specify poison as return value and not UB. You can say: "If the return value is not poison, it points into the same object as the first argument did."




================
Comment at: llvm/include/llvm/IR/Intrinsics.td:1025
+// Intrinsic to mask out bits of a pointer that must be zero when the pointer
+// is used to access memory.
+def int_ptrmask: Intrinsic<[llvm_anyptr_ty], [llvm_anyptr_ty, llvm_anyint_ty], [IntrNoMem]>;
----------------
I'd drop the latter part. The intrinsic masks out bits. That some architectures require these bits to be 0 when the pointer is "just a use case".




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

https://reviews.llvm.org/D59065





More information about the llvm-commits mailing list