[clang] [HIP] Don't add -fvisibility=hidden for SPIR-V compilation flow (PR #184821)

Dmitry Sidorov via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 09:20:44 PST 2026


MrSidims wrote:

> What failure are you experiencing?

It's a crash within SPIR-V backend. Obviously the crash must (and will) be fixed. Small reproducer:
```
declare hidden spir_func void @hidden_helper(ptr addrspace(1))

; Kernel calling the hidden function
define spir_kernel void @test_kernel(ptr addrspace(1) %data) {
entry:
  call spir_func void @hidden_helper(ptr addrspace(1) %data)
  ret void
}
```

> I'm guessing this is related to the external Khronos tools?

No, external tools are happy with hidden visibility in a way of just ignoring it, so if we use https://github.com/KhronosGroup/SPIRV-LLVM-Translator after the LLVM IR -> SPIR-V ->LLVM IR roundtrip we just have a default visibility (in this regard, my patch is NFC for existing amdgcnspirv flow).

> CUDA / PTX didn't really accept visibility until very recently and the backend didn't have any issues.

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp#L36 - it's just ignored.

For HIP, from my perspective it's better to adjust both frontend driver and the backend, ignoring hidden visibility in SPIR-V compilation flow.

https://github.com/llvm/llvm-project/pull/184821


More information about the cfe-commits mailing list