Skip to content

Commit d655054

Browse files
authored
Revert "[DirectX] Fix DXIL part header version encoding" (#91791)
Test failures on big endian bots after this change. Reverts #91506
1 parent 13af97a commit d655054

File tree

6 files changed

+11
-61
lines changed

6 files changed

+11
-61
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ struct PartHeader {
103103

104104
struct BitcodeHeader {
105105
uint8_t Magic[4]; // ACSII "DXIL".
106-
uint8_t MinorVersion; // DXIL version.
107106
uint8_t MajorVersion; // DXIL version.
107+
uint8_t MinorVersion; // DXIL version.
108108
uint16_t Unused;
109109
uint32_t Offset; // Offset to LLVM bitcode (from start of header).
110110
uint32_t Size; // Size of LLVM bitcode (in bytes).

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class Triple {
429429
/// (SubArch). This should only be called with Vulkan SPIR-V triples.
430430
VersionTuple getVulkanVersion() const;
431431

432-
/// Parse the DXIL version number from the OSVersion and DXIL version
432+
/// Parse the DXIL version number from the DXIL version
433433
/// (SubArch). This should only be called with DXIL triples.
434434
VersionTuple getDXILVersion() const;
435435

llvm/lib/MC/MCDXContainerWriter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
127127
// The program header's size field is in 32-bit words.
128128
Header.Size = (SectionSize + sizeof(dxbc::ProgramHeader) + 3) / 4;
129129
memcpy(Header.Bitcode.Magic, "DXIL", 4);
130-
VersionTuple DXILVersion = TT.getDXILVersion();
131-
Header.Bitcode.MajorVersion = DXILVersion.getMajor();
132-
Header.Bitcode.MinorVersion = DXILVersion.getMinor().value_or(0);
133130
Header.Bitcode.Offset = sizeof(dxbc::BitcodeHeader);
134131
Header.Bitcode.Size = SectionSize;
135132
if (sys::IsBigEndianHost)

llvm/lib/TargetParser/Triple.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,8 +1510,6 @@ VersionTuple Triple::getDXILVersion() const {
15101510
if (getArch() != dxil || getOS() != ShaderModel)
15111511
llvm_unreachable("invalid DXIL triple");
15121512
StringRef Arch = getArchName();
1513-
if (getSubArch() == NoSubArch)
1514-
Arch = getDXILArchNameFromShaderModel(getOSName());
15151513
Arch.consume_front("dxilv");
15161514
VersionTuple DXILVersion = parseVersionFromName(Arch);
15171515
// FIXME: validate DXIL version against Shader Model version.

llvm/test/CodeGen/DirectX/embed-dxil.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ define i32 @add(i32 %a, i32 %b) {
4242
; DXC-NEXT: MinorVersion: 5
4343
; DXC-NEXT: ShaderKind: 6
4444
; DXC-NEXT: Size: [[#div(SIZE,4)]]
45-
; DXC-NEXT: DXILMajorVersion: 1
46-
; DXC-NEXT: DXILMinorVersion: 5
45+
; DXC-NEXT: DXILMajorVersion: [[#]]
46+
; DXC-NEXT: DXILMinorVersion: [[#]]
4747
; DXC-NEXT: DXILSize: [[#SIZE - 24]]
4848
; DXC-NEXT: DXIL: [ 0x42, 0x43, 0xC0, 0xDE,
4949
; DXC: - Name: SFI0

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -126,51 +126,6 @@ TEST(DXCFile, ParseOverlappingParts) {
126126
"Part offset for part 1 begins before the previous part ends"));
127127
}
128128

129-
// This test verify DXILMajorVersion and DXILMinorVersion are correctly parsed.
130-
// This test is based on the binary output constructed from this yaml.
131-
// --- !dxcontainer
132-
// Header:
133-
// Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
134-
// 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
135-
// Version:
136-
// Major: 1
137-
// Minor: 0
138-
// PartCount: 1
139-
// Parts:
140-
// - Name: DXIL
141-
// Size: 28
142-
// Program:
143-
// MajorVersion: 6
144-
// MinorVersion: 5
145-
// ShaderKind: 5
146-
// Size: 8
147-
// DXILMajorVersion: 1
148-
// DXILMinorVersion: 5
149-
// DXILSize: 4
150-
// DXIL: [ 0x42, 0x43, 0xC0, 0xDE, ]
151-
// ...
152-
TEST(DXCFile, ParseDXILPart) {
153-
uint8_t Buffer[] = {
154-
0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
156-
0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
157-
0x44, 0x58, 0x49, 0x4c, 0x1c, 0x00, 0x00, 0x00, 0x65, 0x00, 0x05, 0x00,
158-
0x08, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, 0x05, 0x01, 0x00, 0x00,
159-
0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde};
160-
DXContainer C =
161-
llvm::cantFail(DXContainer::create(getMemoryBuffer<116>(Buffer)));
162-
EXPECT_EQ(C.getHeader().PartCount, 1u);
163-
const std::optional<object::DXContainer::DXILData> &DXIL = C.getDXIL();
164-
EXPECT_TRUE(DXIL.has_value());
165-
dxbc::ProgramHeader Header = DXIL->first;
166-
EXPECT_EQ(Header.MajorVersion, 6u);
167-
EXPECT_EQ(Header.MinorVersion, 5u);
168-
EXPECT_EQ(Header.ShaderKind, 5u);
169-
EXPECT_EQ(Header.Size, 8u);
170-
EXPECT_EQ(Header.Bitcode.MajorVersion, 1u);
171-
EXPECT_EQ(Header.Bitcode.MinorVersion, 5u);
172-
}
173-
174129
TEST(DXCFile, ParseEmptyParts) {
175130
uint8_t Buffer[] = {
176131
0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -285,8 +240,8 @@ TEST(DXCFile, PSVResourceIterators) {
285240
MinorVersion: 0
286241
ShaderKind: 14
287242
Size: 6
288-
DXILMajorVersion: 1
289-
DXILMinorVersion: 0
243+
DXILMajorVersion: 0
244+
DXILMinorVersion: 1
290245
DXILSize: 0
291246
...
292247
)";
@@ -406,8 +361,8 @@ TEST(DXCFile, PSVResourceIterators) {
406361
// MinorVersion: 0
407362
// ShaderKind: 14
408363
// Size: 6
409-
// DXILMajorVersion: 1
410-
// DXILMinorVersion: 0
364+
// DXILMajorVersion: 0
365+
// DXILMinorVersion: 1
411366
// DXILSize: 0
412367
// - Name: PSV0
413368
// Size: 36
@@ -522,7 +477,7 @@ TEST(DXCFile, MaliciousFiles) {
522477
//
523478
// --- !dxcontainer
524479
// Header:
525-
// Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
480+
// Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
526481
// 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
527482
// Version:
528483
// Major: 1
@@ -536,8 +491,8 @@ TEST(DXCFile, MaliciousFiles) {
536491
// MinorVersion: 0
537492
// ShaderKind: 14
538493
// Size: 6
539-
// DXILMajorVersion: 1
540-
// DXILMinorVersion: 0
494+
// DXILMajorVersion: 0
495+
// DXILMinorVersion: 1
541496
// DXILSize: 0
542497
// - Name: PSV0
543498
// Size: 100

0 commit comments

Comments
 (0)