[PATCH] D67295: [COFF] Fix to not add archive name to buffer identifiers when they come from thin archives.

Amy Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 11:13:08 PDT 2019


akhuang created this revision.
akhuang added reviewers: rnk, inglorion.
Herald added subscribers: llvm-commits, ychen, arphaman, dexonsmith, steven_wu, mehdi_amini.
Herald added a project: LLVM.

Currently lld adds the archive name to MemoryBufferRef identifiers in order to
ensure they are unique. For thin archives, since the file name is already unique and we
want to keep the original path to the file, don't add the archive name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67295

Files:
  lld/COFF/Driver.cpp
  lld/test/COFF/thinlto-index-only.ll


Index: lld/test/COFF/thinlto-index-only.ll
===================================================================
--- lld/test/COFF/thinlto-index-only.ll
+++ lld/test/COFF/thinlto-index-only.ll
@@ -41,6 +41,17 @@
 ; BACKEND2-NEXT: <COMBINED
 ; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
 
+; Thin archive tests. Check that the module paths point to the original files.
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: opt -thinlto-bc -o %t/foo.obj < %s
+; RUN: opt -thinlto-bc -o %t/bar.obj < %p/Inputs/thinlto.ll
+; RUN: llvm-ar rcsT %t5.lib %t/bar.obj %t3.obj
+; RUN: lld-link -thinlto-index-only -entry:main %t/foo.obj %t5.lib
+; RUN: llvm-dis -o - %t/foo.obj.thinlto.bc | FileCheck %s --check-prefix=THINARCHIVE
+; THINARCHIVE: ^0 = module: (path: "{{.*}}foo.obj",
+; THINARCHIVE: ^1 = module: (path: "{{.*}}bar.obj",
+
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-windows-msvc19.0.24215"
 
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -309,9 +309,10 @@
     auto mbOrErr = future->get();
     if (mbOrErr.second)
       reportBufferError(errorCodeToError(mbOrErr.second), childName);
+    // Pass empty string as archive name so that the original filename is
+    // used as the buffer identifier.
     driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
-                             toCOFFString(sym), parentName,
-                             /*OffsetInArchive=*/0);
+                             toCOFFString(sym), "", /*OffsetInArchive=*/0);
   });
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67295.219146.patch
Type: text/x-patch
Size: 1609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190906/6f278ebd/attachment.bin>


More information about the llvm-commits mailing list