[all-commits] [llvm/llvm-project] eb86de: [IR] Require that ptrmask mask matches pointer ind...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Oct 24 00:54:42 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb86de63d901941fba0a54eb41551456447cd789
      https://github.com/llvm/llvm-project/commit/eb86de63d901941fba0a54eb41551456447cd789
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2023-10-24 (Tue, 24 Oct 2023)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/CodeGen/AArch64/lower-ptrmask.ll
    M llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-ptrmask.ll
    M llvm/test/CodeGen/AMDGPU/ptrmask.ll
    M llvm/test/CodeGen/X86/lower-ptrmask.ll
    M llvm/test/Transforms/InferAddressSpaces/AMDGPU/ptrmask.ll
    M llvm/test/Transforms/InferAlignment/ptrmask.ll
    M llvm/test/Transforms/InstCombine/align-addr.ll
    M llvm/test/Transforms/InstCombine/consecutive-ptrmask.ll
    M llvm/test/Verifier/ptrmask.ll

  Log Message:
  -----------
  [IR] Require that ptrmask mask matches pointer index size (#69343)

Currently, we specify that the ptrmask intrinsic allows the mask to have
any size, which will be zero-extended or truncated to the pointer size.

However, what semantics of the specified GEP expansion actually imply is
that the mask is only meaningful up to the pointer type *index* size --
any higher bits of the pointer will always be preserved. In other words,
the mask gets 1-extended from the index size to the pointer size. This
is also the behavior we want for CHERI architectures.

This PR makes two changes:
* It spells out the interaction with the pointer type index size more
explicitly.
* It requires that the mask matches the pointer type index size. The
intention here is to make handling of this intrinsic more robust, to
avoid accidental mix-ups of pointer size and index size in code
generating this intrinsic. If a zero-extend or truncate of the mask is
desired, it should just be done explicitly in IR. This also cuts down on
the amount of testing we have to do, and things transforms needs to
check for.

As far as I can tell, we don't actually support pointers with different
index type size at the SDAG level, so I'm just asserting the sizes match
there for now. Out-of-tree targets using different index sizes may need
to adjust that code.




More information about the All-commits mailing list