[DirectX backend] PartSize not include PartHeader
authorXiang Li <python3kgae@outlook.com>
Sun, 8 Jan 2023 04:31:26 +0000 (23:31 -0500)
committerXiang Li <python3kgae@outlook.com>
Tue, 10 Jan 2023 00:10:21 +0000 (19:10 -0500)
PartSize for a part in dx container is only the size of the content of the part, not include size of the PartHeader.

Differential Revision: https://reviews.llvm.org/D141207

llvm/lib/MC/MCDXContainerWriter.cpp
llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
llvm/test/CodeGen/DirectX/ShaderFlags/double-extensions.ll
llvm/test/CodeGen/DirectX/ShaderFlags/doubles.ll
llvm/test/CodeGen/DirectX/embed-dxil.ll

index ddccc10..028bfe6 100644 (file)
@@ -104,7 +104,7 @@ uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
     // Write section header.
     W.write<char>(ArrayRef<char>(Sec.getName().data(), 4));
 
-    uint64_t PartSize = SectionSize + sizeof(dxbc::PartHeader);
+    uint64_t PartSize = SectionSize;
 
     if (Sec.getName() == "DXIL")
       PartSize += sizeof(dxbc::ProgramHeader);
index 8e69242..2678826 100644 (file)
@@ -19,7 +19,7 @@ define i32 @add(i32 %a, i32 %b) {
 !4 = !{i32 2, !"Debug Info Version", i32 3}
 
 ; DXC: - Name:            HASH
-; DXC:   Size:            28
+; DXC:   Size:            20
 ; DXC:   Hash:
 ; DXC:     IncludesSource:  true
 ; DXC:     Digest:          [ 
index 327d355..0200872 100644 (file)
@@ -10,7 +10,7 @@ define i32 @add(i32 %a, i32 %b) {
 }
 
 ; DXC: - Name:            HASH
-; DXC:   Size:            28
+; DXC:   Size:            20
 ; DXC:   Hash:
 ; DXC:     IncludesSource:  false
 ; DXC:     Digest:          [ 
index 26487ca..865fefe 100644 (file)
@@ -15,7 +15,7 @@ define double @div(double %a, double %b) {
 
 
 ; DXC: - Name:            SFI0
-; DXC-NEXT:     Size:            16
+; DXC-NEXT:     Size:            8
 ; DXC-NEXT:     Flags:
 ; DXC-NEXT:       Doubles:         true
 ; DXC-NOT:   {{[A-Za-z]+: +true}}
index 95320dd..f90db61 100644 (file)
@@ -13,7 +13,7 @@ define double @add(double %a, double %b) {
 }
 
 ; DXC: - Name:            SFI0
-; DXC-NEXT:     Size:            16
+; DXC-NEXT:     Size:            8
 ; DXC-NEXT:     Flags:
 ; DXC-NEXT:       Doubles:         true
 ; DXC-NOT:   {{[A-Za-z]+: +true}}
index bea6f60..b9a3e8c 100644 (file)
@@ -42,11 +42,11 @@ define i32 @add(i32 %a, i32 %b) {
 ; DXC-NEXT:       MajorVersion:    6
 ; DXC-NEXT:       MinorVersion:    5
 ; DXC-NEXT:       ShaderKind:      6
-; DXC-NEXT:       Size:            [[#div(SIZE,4) - 2]]
+; DXC-NEXT:       Size:            [[#div(SIZE,4)]]
 ; DXC-NEXT:       DXILMajorVersion: [[#]]
 ; DXC-NEXT:       DXILMinorVersion: [[#]]
-; DXC-NEXT:       DXILSize:        [[#SIZE - 32]]
+; DXC-NEXT:       DXILSize:        [[#SIZE - 24]]
 ; DXC-NEXT:       DXIL:            [ 0x42, 0x43, 0xC0, 0xDE,
 ; DXC:      - Name:            SFI0
-; DXC-NEXT:   Size:            16
+; DXC-NEXT:   Size:            8
 ; DXC-NOT:    Flags: