This revision was automatically updated to reflect the committed changes. Closed by commit rG4c7218e77026: [HLSL] Remove unused frontend-generated ID (authored by beanz).
Changed prior to commit: https://reviews.llvm.org/D136271?vs=468961&id=469681#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136271/new/ https://reviews.llvm.org/D136271 Files: clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl clang/test/CodeGenHLSL/cbuf.hlsl llvm/include/llvm/Frontend/HLSL/HLSLResource.h llvm/lib/Frontend/HLSL/HLSLResource.cpp llvm/test/CodeGen/DirectX/UAVMetadata.ll
Index: llvm/test/CodeGen/DirectX/UAVMetadata.ll =================================================================== --- llvm/test/CodeGen/DirectX/UAVMetadata.ll +++ llvm/test/CodeGen/DirectX/UAVMetadata.ll @@ -37,16 +37,16 @@ !hlsl.uavs = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9} -!0 = !{ptr @Zero, !"RWBuffer<half>", i32 0, i32 10, i32 0, i32 0} -!1 = !{ptr @One, !"Buffer<vector<float,4>>", i32 1, i32 10, i32 1, i32 0} -!2 = !{ptr @Two, !"Buffer<double>", i32 2, i32 10, i32 2, i32 0} -!3 = !{ptr @Three, !"Buffer<bool>", i32 3, i32 10, i32 3, i32 0} -!4 = !{ptr @Four, !"ByteAddressBuffer<int16_t>", i32 4, i32 11, i32 5, i32 0} -!5 = !{ptr @Five, !"StructuredBuffer<uint16_t>", i32 5, i32 12, i32 6, i32 0} -!6 = !{ptr @Six, !"RasterizerOrderedBuffer<int32_t>", i32 6, i32 10, i32 7, i32 0} -!7 = !{ptr @Seven, !"RasterizerOrderedStructuredBuffer<uint32_t>", i32 7, i32 12, i32 8, i32 0} -!8 = !{ptr @Eight, !"RasterizerOrderedByteAddressBuffer<int64_t>", i32 8, i32 11, i32 9, i32 0} -!9 = !{ptr @Nine, !"RWBuffer<uint64_t>", i32 9, i32 10, i32 10, i32 2} +!0 = !{ptr @Zero, !"RWBuffer<half>", i32 10, i32 0, i32 0} +!1 = !{ptr @One, !"Buffer<vector<float,4>>", i32 10, i32 1, i32 0} +!2 = !{ptr @Two, !"Buffer<double>", i32 10, i32 2, i32 0} +!3 = !{ptr @Three, !"Buffer<bool>", i32 10, i32 3, i32 0} +!4 = !{ptr @Four, !"ByteAddressBuffer<int16_t>", i32 11, i32 5, i32 0} +!5 = !{ptr @Five, !"StructuredBuffer<uint16_t>", i32 12, i32 6, i32 0} +!6 = !{ptr @Six, !"RasterizerOrderedBuffer<int32_t>", i32 10, i32 7, i32 0} +!7 = !{ptr @Seven, !"RasterizerOrderedStructuredBuffer<uint32_t>", i32 12, i32 8, i32 0} +!8 = !{ptr @Eight, !"RasterizerOrderedByteAddressBuffer<int64_t>", i32 11, i32 9, i32 0} +!9 = !{ptr @Nine, !"RWBuffer<uint64_t>", i32 10, i32 10, i32 2} ; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]} Index: llvm/lib/Frontend/HLSL/HLSLResource.cpp =================================================================== --- llvm/lib/Frontend/HLSL/HLSLResource.cpp +++ llvm/lib/Frontend/HLSL/HLSLResource.cpp @@ -27,34 +27,29 @@ return cast<MDString>(Entry->getOperand(1))->getString(); } -Constant *FrontendResource::getID() { - return cast<ConstantAsMetadata>(Entry->getOperand(2))->getValue(); -} - uint32_t FrontendResource::FrontendResource::getResourceKind() { return cast<ConstantInt>( - cast<ConstantAsMetadata>(Entry->getOperand(3))->getValue()) + cast<ConstantAsMetadata>(Entry->getOperand(2))->getValue()) ->getLimitedValue(); } uint32_t FrontendResource::getResourceIndex() { return cast<ConstantInt>( - cast<ConstantAsMetadata>(Entry->getOperand(4))->getValue()) + cast<ConstantAsMetadata>(Entry->getOperand(3))->getValue()) ->getLimitedValue(); } uint32_t FrontendResource::getSpace() { return cast<ConstantInt>( - cast<ConstantAsMetadata>(Entry->getOperand(5))->getValue()) + cast<ConstantAsMetadata>(Entry->getOperand(4))->getValue()) ->getLimitedValue(); } FrontendResource::FrontendResource(GlobalVariable *GV, StringRef TypeStr, - uint32_t Counter, ResourceKind RK, - uint32_t ResIndex, uint32_t Space) { + ResourceKind RK, uint32_t ResIndex, + uint32_t Space) { auto &Ctx = GV->getContext(); IRBuilder<> B(Ctx); Entry = MDNode::get( Ctx, {ValueAsMetadata::get(GV), MDString::get(Ctx, TypeStr), - ConstantAsMetadata::get(B.getInt32(Counter)), ConstantAsMetadata::get(B.getInt32(static_cast<int>(RK))), ConstantAsMetadata::get(B.getInt32(ResIndex)), ConstantAsMetadata::get(B.getInt32(Space))}); Index: llvm/include/llvm/Frontend/HLSL/HLSLResource.h =================================================================== --- llvm/include/llvm/Frontend/HLSL/HLSLResource.h +++ llvm/include/llvm/Frontend/HLSL/HLSLResource.h @@ -60,15 +60,14 @@ public: FrontendResource(MDNode *E) : Entry(E) { - assert(Entry->getNumOperands() == 6 && "Unexpected metadata shape"); + assert(Entry->getNumOperands() == 5 && "Unexpected metadata shape"); } - FrontendResource(GlobalVariable *GV, StringRef TypeStr, uint32_t Counter, - ResourceKind RK, uint32_t ResIndex, uint32_t Space); + FrontendResource(GlobalVariable *GV, StringRef TypeStr, ResourceKind RK, + uint32_t ResIndex, uint32_t Space); GlobalVariable *getGlobalVariable(); StringRef getSourceType(); - Constant *getID(); uint32_t getResourceKind(); uint32_t getResourceIndex(); uint32_t getSpace(); Index: clang/test/CodeGenHLSL/cbuf.hlsl =================================================================== --- clang/test/CodeGenHLSL/cbuf.hlsl +++ clang/test/CodeGenHLSL/cbuf.hlsl @@ -24,5 +24,5 @@ // CHECK: !hlsl.cbufs = !{![[CBMD:[0-9]+]]} // CHECK: !hlsl.srvs = !{![[TBMD:[0-9]+]]} -// CHECK: ![[CBMD]] = !{ptr @[[CB]], !"A.cb.ty", i32 0, i32 13, i32 0, i32 2} -// CHECK: ![[TBMD]] = !{ptr @[[TB]], !"A.tb.ty", i32 0, i32 15, i32 2, i32 1} +// CHECK: ![[CBMD]] = !{ptr @[[CB]], !"A.cb.ty", i32 13, i32 0, i32 2} +// CHECK: ![[TBMD]] = !{ptr @[[TB]], !"A.tb.ty", i32 15, i32 2, i32 1} Index: clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl =================================================================== --- clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl +++ clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl @@ -16,9 +16,9 @@ } // CHECK: !hlsl.uavs = !{![[Single:[0-9]+]], ![[Array:[0-9]+]], ![[SingleAllocated:[0-9]+]], ![[ArrayAllocated:[0-9]+]], ![[SingleSpace:[0-9]+]], ![[ArraySpace:[0-9]+]]} -// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 0, i32 10, i32 -1, i32 0} -// CHECK-DAG: ![[Array]] = !{ptr @"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 1, i32 10, i32 -1, i32 0} -// CHECK-DAG: ![[SingleAllocated]] = !{ptr @"?Buffer2@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 2, i32 10, i32 3, i32 0} -// CHECK-DAG: ![[ArrayAllocated]] = !{ptr @"?BufferArray2@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 3, i32 10, i32 4, i32 0} -// CHECK-DAG: ![[SingleSpace]] = !{ptr @"?Buffer3@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 4, i32 10, i32 3, i32 1} -// CHECK-DAG: ![[ArraySpace]] = !{ptr @"?BufferArray3@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 5, i32 10, i32 4, i32 1} +// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 10, i32 -1, i32 0} +// CHECK-DAG: ![[Array]] = !{ptr @"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 10, i32 -1, i32 0} +// CHECK-DAG: ![[SingleAllocated]] = !{ptr @"?Buffer2@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 10, i32 3, i32 0} +// CHECK-DAG: ![[ArrayAllocated]] = !{ptr @"?BufferArray2@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 10, i32 4, i32 0} +// CHECK-DAG: ![[SingleSpace]] = !{ptr @"?Buffer3@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer<float>", i32 10, i32 3, i32 1} +// CHECK-DAG: ![[ArraySpace]] = !{ptr @"?BufferArray3@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", !"RWBuffer<vector<float, 4> >", i32 10, i32 4, i32 1} Index: clang/lib/CodeGen/CGHLSLRuntime.h =================================================================== --- clang/lib/CodeGen/CGHLSLRuntime.h +++ clang/lib/CodeGen/CGHLSLRuntime.h @@ -70,8 +70,6 @@ protected: CodeGenModule &CGM; - uint32_t ResourceCounters[static_cast<uint32_t>( - llvm::hlsl::ResourceClass::NumClasses)] = {0}; llvm::Value *emitInputSemantic(llvm::IRBuilder<> &B, const ParmVarDecl &D, llvm::Type *Ty); Index: clang/lib/CodeGen/CGHLSLRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGHLSLRuntime.cpp +++ clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -197,7 +197,6 @@ llvm::hlsl::ResourceClass RC, llvm::hlsl::ResourceKind RK, BufferResBinding &Binding) { - uint32_t Counter = ResourceCounters[static_cast<uint32_t>(RC)]++; llvm::Module &M = CGM.getModule(); NamedMDNode *ResourceMD = nullptr; @@ -220,7 +219,7 @@ "ResourceMD must have been set by the switch above."); llvm::hlsl::FrontendResource Res( - GV, TyName, Counter, RK, Binding.Reg.value_or(UINT_MAX), Binding.Space); + GV, TyName, RK, Binding.Reg.value_or(UINT_MAX), Binding.Space); ResourceMD->addOperand(Res.getMetadata()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits