[all-commits] [llvm/llvm-project] 790938: [HLSL] Set visibility of cbuffer global variables ...
Helena Kotas via All-commits
all-commits at lists.llvm.org
Thu Jun 11 13:40:57 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 790938d0204af8307d7d37b3e10caef27b3d527f
https://github.com/llvm/llvm-project/commit/790938d0204af8307d7d37b3e10caef27b3d527f
Author: Helena Kotas <hekotas at microsoft.com>
Date: 2026-06-11 (Thu, 11 Jun 2026)
Changed paths:
M clang/lib/CodeGen/CGHLSLRuntime.cpp
M clang/test/CodeGenHLSL/ArrayAssignable.hlsl
M clang/test/CodeGenHLSL/ArrayAssignable.logicalptr.hlsl
M clang/test/CodeGenHLSL/cbuffer-matrix-layout-keyword.hlsl
M clang/test/CodeGenHLSL/resources/cbuffer-empty-struct-array.hlsl
M clang/test/CodeGenHLSL/resources/cbuffer.hlsl
M clang/test/CodeGenHLSL/resources/cbuffer_and_namespaces.hlsl
M clang/test/CodeGenHLSL/resources/cbuffer_with_packoffset.hlsl
M clang/test/CodeGenHLSL/resources/cbuffer_with_static_global_and_function.hlsl
M clang/test/CodeGenHLSL/resources/default_cbuffer.hlsl
M clang/test/CodeGenHLSL/resources/default_cbuffer_with_layout.hlsl
M llvm/include/llvm/Frontend/HLSL/CBuffer.h
M llvm/lib/Frontend/HLSL/CBuffer.cpp
M llvm/lib/Target/DirectX/DXILCBufferAccess.cpp
M llvm/lib/Target/SPIRV/SPIRVCBufferAccess.cpp
A llvm/test/CodeGen/DirectX/cbuffer_global_elim.ll
A llvm/test/CodeGen/SPIRV/cbuffer_global_elim.ll
Log Message:
-----------
[HLSL] Set visibility of cbuffer global variables to internal (2nd attempt) (#202745)
Global variables for all resources except `cbuffer` are already emitted
with internal linkage (since #166844).
This change adds internal linkage to the `cbuffer` handle globals as
well.
One problem is that the `cbuffer` handle globals appears unused between
Clang CodeGen and `{DXIL|SPIRV}CBufferAccess` pass, which replaces
individual `cbuffer` constant globals with accesses through the
`cbuffer` handle globals. Before this pass runs, the unused globals
could get optimized away in `GlobalOptPass` with `-O3`.
To solve this, the `cbuffer` handle globals are added to the
`@llvm.compiler.used` list to make sure they stay in the module until
the `{DXIL|SPRIV}CBufferAccess` pass, which then removes them from the
list.
This is a second attempt to land this change. The [first
one](https://github.com/llvm/llvm-project/pull/200312) had to be
reverted because the use of `llvm::removeFromUsedList` introduced a
cyclic dependency between `LLVMTransformUtils` and `LLVMFrontendHLSL`.
This change fixes this by calling `llvm::removeFromUsedList` directly
from the passes.
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