[llvm] 8de2ecc - [ExecutionEngine] Fix the call to DWARFContext::create

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 1 15:54:08 PDT 2023


Author: Kazu Hirata
Date: 2023-10-01T15:53:53-07:00
New Revision: 8de2ecc2e75d496fc7fc8a24c3acf71732a3bd0c

URL: https://github.com/llvm/llvm-project/commit/8de2ecc2e75d496fc7fc8a24c3acf71732a3bd0c
DIFF: https://github.com/llvm/llvm-project/commit/8de2ecc2e75d496fc7fc8a24c3acf71732a3bd0c.diff

LOG: [ExecutionEngine] Fix the call to DWARFContext::create

Without this patch, we pass G.getEndianness() as one of the parameters
to DWARFContext::create.  The problem is that G.getEndianness() is of:

  enum endianness {big, little, native};

whereas DWARFContext::create is expecting "bool isLittleEndian".  That
is, we are relying on an implicit conversion to convert big and little
to false and true, respectively.

When we migrate llvm::support::endianness to std::endian in future, we
can no longer rely on an implicit conversion because std::endian is
declared with "enum class".  Even if we could, the conversion would
not be guaranteed to work because, for example, libcxx defines:

  enum class endian {
    little = 0xDEAD,
    big = 0xFACE,
    :

where big and little are not boolean values.

This patch fixes the problem by properly converting G.getEndianness()
to a boolean value.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
index 13a0f83da8b5158..2f70a11944e71f3 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
@@ -158,8 +158,12 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
 
     std::optional<StringRef> FileName;
     if (!DebugLineSectionData.empty()) {
+      assert((G.getEndianness() == support::endianness::big ||
+              G.getEndianness() == support::endianness::little) &&
+             "G.getEndianness() must be either big or little");
       auto DWARFCtx = DWARFContext::create(DebugSectionMap, G.getPointerSize(),
-                                           G.getEndianness());
+                                           G.getEndianness() ==
+                                               support::endianness::little);
       DWARFDataExtractor DebugLineData(
           DebugLineSectionData,
           G.getEndianness() == support::endianness::little, G.getPointerSize());


        


More information about the llvm-commits mailing list