diff --git a/llvm/lib/MC/DXContainerPSVInfo.cpp b/llvm/lib/MC/DXContainerPSVInfo.cpp index 399f54c8332f8..48a987eb03765 100644 --- a/llvm/lib/MC/DXContainerPSVInfo.cpp +++ b/llvm/lib/MC/DXContainerPSVInfo.cpp @@ -26,10 +26,11 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { default: InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo); } + uint32_t InfoSizeSwapped = InfoSize; if (sys::IsBigEndianHost) - sys::swapByteOrder(InfoSize); + sys::swapByteOrder(InfoSizeSwapped); // Write the size of the info. - OS.write(reinterpret_cast(&InfoSize), sizeof(uint32_t)); + OS.write(reinterpret_cast(&InfoSizeSwapped), sizeof(uint32_t)); // Write the info itself. OS.write(reinterpret_cast(&BaseData), InfoSize); }