[llvm] r274148 - Don't verify inputs to the Linker if ODR merging.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 11:31:49 PDT 2016


Author: rafael
Date: Wed Jun 29 13:31:48 2016
New Revision: 274148

URL: http://llvm.org/viewvc/llvm-project?rev=274148&view=rev
Log:
Don't verify inputs to the Linker if ODR merging.

This fixes pr28072.

The point, as Duncan pointed out, is that the file is already
partially linked by just reading it.

Long term I think the solution is to make metadata owned by the module
and then the linker will lazily read it and be in charge of all the
linking. Running a verifier in each input will defeat the lazy
loading, but will be legal.

Right now we are at the unfortunate position that to support odr
merging we cannot verify the inputs, which mildly annoying (see test
update).

Added:
    llvm/trunk/test/Linker/Inputs/odr.ll
    llvm/trunk/test/Linker/odr.ll
Modified:
    llvm/trunk/test/Linker/broken.ll
    llvm/trunk/tools/llvm-link/llvm-link.cpp

Added: llvm/trunk/test/Linker/Inputs/odr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/odr.ll?rev=274148&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/odr.ll (added)
+++ llvm/trunk/test/Linker/Inputs/odr.ll Wed Jun 29 13:31:48 2016
@@ -0,0 +1,8 @@
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, retainedTypes: !2)
+!1 = !DIFile(filename: "../../src/core/weakHashTable.cc", directory: "/Users/meister/Development/clasp/wbuild/clasp_boehm_o")
+!2 = !{!3}
+!3 = distinct !DICompositeType(tag: DW_TAG_class_type, file: !1, identifier: "zed")
+!4 = !{i32 2, !"Debug Info Version", i32 3}

Modified: llvm/trunk/test/Linker/broken.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/broken.ll?rev=274148&r1=274147&r2=274148&view=diff
==============================================================================
--- llvm/trunk/test/Linker/broken.ll (original)
+++ llvm/trunk/test/Linker/broken.ll Wed Jun 29 13:31:48 2016
@@ -1,4 +1,4 @@
-; RUN: not llvm-link -o /dev/null %s 2>&1 | FileCheck %s
+; RUN: not llvm-link -disable-debug-info-type-map -o /dev/null %s 2>&1 | FileCheck %s
 
 ; CHECK: broken.ll: error: input module is broken!
 define i32 @foo(i32 %v) {

Added: llvm/trunk/test/Linker/odr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/odr.ll?rev=274148&view=auto
==============================================================================
--- llvm/trunk/test/Linker/odr.ll (added)
+++ llvm/trunk/test/Linker/odr.ll Wed Jun 29 13:31:48 2016
@@ -0,0 +1,18 @@
+; Use llvm-as to verify each module
+; RUN: llvm-as %s -o %t1.bc
+; RUN: llvm-as %p/Inputs/odr.ll -o %t2.bc
+; Check that we can link it
+; RUN: llvm-link %t1.bc %t2.bc -o %t
+ at bar = global i64 0, align 8
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, retainedTypes: !2, globals: !5)
+!1 = !DIFile(filename: "a", directory: "")
+!2 = !{!3}
+!3 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !4, file: !1, identifier: "zed")
+!4 = distinct !DISubprogram(name: "b", scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!5 = !{!6}
+!6 = distinct !DIGlobalVariable(name: "c", scope: null, isLocal: false, isDefinition: true, variable: i64* @bar)
+!7 = !{i32 2, !"Debug Info Version", i32 3}

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=274148&r1=274147&r2=274148&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Wed Jun 29 13:31:48 2016
@@ -299,7 +299,10 @@ static bool linkFiles(const char *argv0,
       return false;
     }
 
-    if (verifyModule(*M, &errs())) {
+    // Note that when ODR merging types cannot verify input files in here When
+    // doing that debug metadata in the src module might already be pointing to
+    // the destination.
+    if (DisableDITypeMap && verifyModule(*M, &errs())) {
       errs() << argv0 << ": " << File << ": error: input module is broken!\n";
       return false;
     }




More information about the llvm-commits mailing list