Skip to content

Conversation

@wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Dec 15, 2025

When the target’s default address space is private (e.g., SPIR), simultaneous pointer address space remangling and long -> long long remangling can cause clone name collisions, preventing the remangled function from being cloned.

Example:
_Z1fPm -> remangled to _Z1fPU3AS0y; remangler clones back to _Z1fPm to preserve the original.
Later, _Z1fPU3AS4m -> remangled to _Z1fPy; we need to clone _Z1fPy to _Z1fPm, but _Z1fPm already exists.

Fix:
Append a temporary suffix to avoid clashes (e.g., _Z1fPm$TmpSuffix). Remove the suffix in post-processing, replacing the old _Z1fPm (clone of _Z1fPU3AS0y) with the new remangled implementation.

llvm-diff shows no change for targets whose default AS isn't private: remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc and remangled-l64-unsigned_char.libspirv-amdgcn-amd-amdhsa.bc.

When the target’s default address space is private (e.g., SPIR), pointer
address space remangling and long -> long long remangling can cause clone
name collisions, preventing the remangled function from being cloned.

Example:
_Z1fPm -> remangled to _Z1fPU3AS0y; remangler clones back to _Z1fPm to
preserve the original.
Later, _Z1fPU3AS4m -> remangled to _Z1fPy; we need to clone _Z1fPy to
_Z1fPm, but _Z1fPm already exists.

Fix:
Append a temporary suffix to avoid clashes (e.g., _Z1fPm$TmpSuffix).
Remove the suffix in post-processing, replacing the old _Z1fPm
(clone of _Z1fPU3AS0y) with the new remangled implementation.

llvm-diff shows no change for targets whose default AS isn't private:
remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc and
remangled-l64-unsigned_char.libspirv-amdgcn-amd-amdhsa.bc.
@wenju-he wenju-he requested a review from a team as a code owner December 15, 2025 02:00
@wenju-he wenju-he requested a review from bratpiorka December 15, 2025 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants