Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)""
authorRaphael Isemann <teemperor@gmail.com>
Mon, 24 Aug 2020 10:54:25 +0000 (12:54 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 24 Aug 2020 10:54:25 +0000 (12:54 +0200)
This reverts commit ada2e8ea67393aa8c44fe8e9d46be62df6d1c702. Still breaking
on Fuchsia (and also Fedora) with exit code 1, so back to investigating.

clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/DebugDwoId.h [deleted file]
clang/test/Modules/Inputs/module.map
clang/test/Modules/ModuleDebugInfoDwoId.cpp [deleted file]

index ac33c75..94dd215 100644 (file)
@@ -62,15 +62,6 @@ struct ASTFileSignature : std::array<uint8_t, 20> {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
-  /// Returns the value truncated to the size of an uint64_t.
-  uint64_t truncatedValue() const {
-    uint64_t Value = 0;
-    static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
-    for (unsigned I = 0; I < sizeof(uint64_t); ++I)
-      Value |= static_cast<uint64_t>((*this)[I]) << (I * 8);
-    return Value;
-  }
-
   static ASTFileSignature create(StringRef Bytes) {
     return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }
index e3442ec..2faf944 100644 (file)
@@ -2545,11 +2545,12 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
     // We use the lower 64 bits for debug info.
 
     uint64_t Signature = 0;
-    if (const auto &ModSig = Mod.getSignature())
-      Signature = ModSig.truncatedValue();
-    else
+    if (const auto &ModSig = Mod.getSignature()) {
+      for (unsigned I = 0; I != sizeof(Signature); ++I)
+        Signature |= (uint64_t)ModSig[I] << (I * 8);
+    } else {
       Signature = ~1ULL;
-
+    }
     llvm::DIBuilder DIB(CGM.getModule());
     SmallString<0> PCM;
     if (!llvm::sys::path::is_absolute(Mod.getASTFile()))
index 04bd668..0c7e5f4 100644 (file)
@@ -250,10 +250,10 @@ public:
     // PCH files don't have a signature field in the control block,
     // but LLVM detects DWO CUs by looking for a non-zero DWO id.
     // We use the lower 64 bits for debug info.
-
     uint64_t Signature =
-        Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
-
+        Buffer->Signature
+            ? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
+            : ~1ULL;
     Builder->getModuleDebugInfo()->setDwoId(Signature);
 
     // Finalize the Builder.
diff --git a/clang/test/Modules/Inputs/DebugDwoId.h b/clang/test/Modules/Inputs/DebugDwoId.h
deleted file mode 100644 (file)
index 242e4c7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef DEBUG_DWO_ID_H
-#define DEBUG_DWO_ID_H
-struct Dummy {};
-#endif
index e7cb4b2..ed220e6 100644 (file)
@@ -357,10 +357,6 @@ module DebugObjCImport {
   }
 }
 
-module DebugDwoId {
-  header "DebugDwoId.h"
-}
-
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
diff --git a/clang/test/Modules/ModuleDebugInfoDwoId.cpp b/clang/test/Modules/ModuleDebugInfoDwoId.cpp
deleted file mode 100644 (file)
index 7a450c2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Tests that dwoIds in modules match the dwoIDs in the main file.
-
-// RUN: rm -rf %t.cache
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out
-// RUN: cat %t.ll > %t.combined_output
-// RUN: cat %t.mod-out >> %t.combined_output
-// RUN: cat %t.combined_output | FileCheck %s
-// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
-// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
-
-@import DebugDwoId;
-
-Dummy d;
-
-// Find the emitted dwoID for DebugInfoId and compare it against the one in the PCM.
-// CHECK: DebugDwoId-{{[A-Z0-9]+}}.pcm
-// CHECK-SAME: dwoId: [[DWOID:[0-9]+]]
-// CHECK: dwoId: [[DWOID]]
-// CHECK-NEXT: !DIFile(filename: "DebugDwoId"
-
-// Make sure the dwo IDs are real IDs and not fallback values (~1ULL).
-// CHECK-REALIDS-NOT: dwoId: 18446744073709551615