[PATCH] D59065: Add ptrmask intrinsic

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 09:25:31 PDT 2019


aqjune added inline comments.


================
Comment at: llvm/docs/LangRef.rst:16406
+of the pointer. Passing masks that zero out relevant bits of the pointer is
+undefined behavior. The relevant bits of a pointer include the bitwidth specified
+in the data layout minus the bits required by the ABI alignment requirement.
----------------
Defining this case as undefined behavior may block code motion.
For example (which does LICM):
```
for (..) {
  if (cond) break;
  p = llvm.ptrmask(p0, mask)
  use(p)
}
=>
p = llvm.ptrmask(p0, mask)
for (..) {
  if (cond) break;
  use(p)
}
```
If cond is false and mask is invalid, the source program has no UB (because the call is never executed), but the optimized program raises UB, which is incorrect.
Defining p as `poison` in this case would resolve the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59065





More information about the llvm-commits mailing list