[all-commits] [llvm/llvm-project] 9aa735: [TargetLowering] Add a new function `getNullPtrValue`

Shilei Tian via All-commits all-commits at lists.llvm.org
Mon Feb 10 20:45:28 PST 2025


  Branch: refs/heads/users/shiltian/non-zero-null-ptr
  Home:   https://github.com/llvm/llvm-project
  Commit: 9aa7353446e8024d3df82d030e81358b157312bf
      https://github.com/llvm/llvm-project/commit/9aa7353446e8024d3df82d030e81358b157312bf
  Author: Shilei Tian <i at tianshilei.me>
  Date:   2025-02-10 (Mon, 10 Feb 2025)

  Changed paths:
    M llvm/include/llvm/CodeGen/TargetLowering.h
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
    A llvm/test/CodeGen/AMDGPU/nullptr-lowering.ll

  Log Message:
  -----------
  [TargetLowering] Add a new function `getNullPtrValue`

In most cases, `nullptr` is a zero-value constant with the corresponding pointer
type. However, this is not always the case. For example, AMDGPU uses
`0xffffffff` as nullptr for AS3 and AS5, leading to lowering issues. Currently,
to ensure correct lowering, `ptr addrspace(5) null` must be written as
`addrspacecast (ptr null to ptr addrspace(5))`.

This PR introduces `TargetLowering::getNullPtrValue` to determine the correct
value of `nullptr`. This helps with proper lowering of `ConstantPointerNull`,
which already has the correct address space.

Fixes #115083.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list