[PATCH] D82827: [DebugInfo] Fix LineTest byteswap for cross-targeting builds

David Tenty via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 17:48:14 PDT 2020


daltenty created this revision.
daltenty added reviewers: jhenderson, hubert.reinterpretcast, stevewan.
Herald added subscribers: llvm-commits, aprantl.
Herald added a project: LLVM.

The byte swap fix for big endian hosts in 9782c922cb21 <https://reviews.llvm.org/rG9782c922cb218cd39b7510be469f61f586414cb7> (for D81570 <https://reviews.llvm.org/D81570>)
swaps based on the host endianess,  but for cross-targeting builds (i.e.
big endian host targeting little endian) the host-endianess won't
necessarily match the generated DWARF.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82827

Files:
  llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp


Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -36,10 +36,13 @@
     EXPECT_FALSE(Unrecoverable);
   }
 
+  Triple getGeneratorTriple(uint8_t AddrSize = 8) {
+    return getDefaultTargetTripleForAddrSize(AddrSize == 0 ? 8 : AddrSize);
+  }
+
   bool setupGenerator(uint16_t Version = 4, uint8_t AddrSize = 8) {
     AddressSize = AddrSize;
-    Triple T =
-        getDefaultTargetTripleForAddrSize(AddressSize == 0 ? 8 : AddressSize);
+    Triple T = getGeneratorTriple(AddressSize);
     if (!isConfigurationSupported(T))
       return false;
     auto ExpectedGenerator = Generator::create(T, Version);
@@ -1443,11 +1446,11 @@
   void SetUp() {
     std::tie(BodyLength, OpcodeLength, Opcode, Operands, ExpectedOutput,
              ExpectedErr) = GetParam();
-    // Swap the byte order of the operands on big endian hosts, so that the raw
-    // bytes are always in the same order. ValLen.Value is a uint64_t, so make
-    // sure to shift the value back to the actually used bits for the
+    // Swap the byte order of the operands on big endian targets, so that the
+    // raw bytes are always in the same order. ValLen.Value is a uint64_t, so
+    // make sure to shift the value back to the actually used bits for the
     // appropriate type.
-    if (sys::IsBigEndianHost)
+    if (!getGeneratorTriple().isLittleEndian())
       for (LineTable::ValueAndLength &ValLen : Operands)
         if (ValLen.Length != LineTable::SLEB &&
             ValLen.Length != LineTable::ULEB &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82827.274295.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200630/4b35989d/attachment-0001.bin>


More information about the llvm-commits mailing list