Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llvm/lib/Analysis/DXILResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,12 @@ void ResourceTypeInfo::print(raw_ostream &OS, const DataLayout &DL) const {

GlobalVariable *ResourceInfo::createSymbol(Module &M, StructType *Ty) {
assert(!Symbol && "Symbol has already been created");
Symbol = new GlobalVariable(M, Ty, /*isConstant=*/true,
Type *ResTy = Ty;
int64_t Size = Binding.Size;
if (Size != 1)
// unbounded arrays are represented as zero-sized arrays in LLVM IR
ResTy = ArrayType::get(Ty, Size == ~0u ? 0 : Size);
Symbol = new GlobalVariable(M, ResTy, /*isConstant=*/true,
GlobalValue::ExternalLinkage,
/*Initializer=*/nullptr, Name);
return Symbol;
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: @Four = external constant %ByteAddressBuffer
; CHECK: @Five = external constant %"StructuredBuffer<int16_t>"
; CHECK: @Six = external constant %"Buffer<uint32_t>"
; CHECK: @Array = external constant %"Buffer<float4>"
; CHECK: @Array2 = external constant %"Buffer<double>"
; CHECK: @Array = external constant [100 x %"Buffer<float4>"]
; CHECK: @Array2 = external constant [0 x %"Buffer<double>"]
; CHECK: @Seven = external constant %"Buffer<uint32_t>"

; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: @Seven = external constant %"RasterizerOrderedStructuredBuffer<int32_t4>"
; CHECK: @Eight = external constant %RasterizerOrderedByteAddressBuffer
; CHECK: @Nine = external constant %"RWBuffer<uint32_t>"
; CHECK: @Array = external constant %"RWBuffer<float4>"
; CHECK: @Array2 = external constant %"RWBuffer<double>"
; CHECK: @Array = external constant [100 x %"RWBuffer<float4>"]
; CHECK: @Array2 = external constant [0 x %"RWBuffer<double>"]
; CHECK: @Ten = external constant %"RWBuffer<uint32_t>"

; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
Expand Down