Skip to content

Commit

Permalink
Fix big endian build bots
Browse files Browse the repository at this point in the history
Another case of reading a value from a struct that has been byte
swapped to write out. This should address the failure on the ppcbe bot.
  • Loading branch information
llvm-beanz committed Jun 7, 2022
1 parent c1d3cfe commit eb68cbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/ObjectYAML/DXContainerEmitter.cpp
Expand Up @@ -144,14 +144,15 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
Header.Size = P.Program->Size.getValue();
else
Header.Size = sizeof(dxbc::ProgramHeader) + Header.Bitcode.Size;

uint32_t BitcodeOffset = Header.Bitcode.Offset;
if (sys::IsBigEndianHost)
Header.swapBytes();
OS.write(reinterpret_cast<const char *>(&Header),
sizeof(dxbc::ProgramHeader));
if (P.Program->DXIL) {
if (Header.Bitcode.Offset > sizeof(dxbc::BitcodeHeader)) {
uint32_t PadBytes =
Header.Bitcode.Offset - sizeof(dxbc::BitcodeHeader);
if (BitcodeOffset > sizeof(dxbc::BitcodeHeader)) {
uint32_t PadBytes = BitcodeOffset - sizeof(dxbc::BitcodeHeader);
OS.write_zeros(PadBytes);
}
OS.write(reinterpret_cast<char *>(P.Program->DXIL->data()),
Expand Down

0 comments on commit eb68cbb

Please sign in to comment.