[llvm] 77272d1 - [COFF] Fix endianness of .llvm.call-graph-profile section data

Zequan Wu via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 11 20:49:50 PDT 2020


Author: Zequan Wu
Date: 2020-07-11T20:49:26-07:00
New Revision: 77272d177a2d7128cf09dc2d27b353cc3e1ecae0

URL: https://github.com/llvm/llvm-project/commit/77272d177a2d7128cf09dc2d27b353cc3e1ecae0
DIFF: https://github.com/llvm/llvm-project/commit/77272d177a2d7128cf09dc2d27b353cc3e1ecae0.diff

LOG: [COFF] Fix endianness of .llvm.call-graph-profile section data

Added: 
    

Modified: 
    llvm/lib/MC/WinCOFFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 94a8d56c55fc..4796ef531054 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1116,9 +1116,9 @@ uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
     for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
       uint32_t FromIndex = CGPE.From->getSymbol().getIndex();
       uint32_t ToIndex = CGPE.To->getSymbol().getIndex();
-      OS.write((const char *)&FromIndex, sizeof(uint32_t));
-      OS.write((const char *)&ToIndex, sizeof(uint32_t));
-      OS.write((const char *)&CGPE.Count, sizeof(uint64_t));
+      support::endian::write(OS, FromIndex, W.Endian);
+      support::endian::write(OS, ToIndex, W.Endian);
+      support::endian::write(OS, CGPE.Count, W.Endian);
     }
   }
 


        


More information about the llvm-commits mailing list