llvm.org GIT mirror llvm / f4becce
Merging r280599: ------------------------------------------------------------------------ r280599 | mehdi.amini | 2016-09-03 14:12:33 -0700 (Sat, 03 Sep 2016) | 10 lines Fix ThinLTO crash with debug info Because the recent change about ODR type uniquing in the context, we can reach types defined in another module during IR linking. This triggered some assertions in case we IR link without starting from an empty module. To alleviate that, we can self-map metadata defined in the destination module so that they won't be visited. Differential Revision: https://reviews.llvm.org/D23841 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@287137 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
4 changed file(s) with 87 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5858
5959 StructType *&operator[](unsigned Idx) { return StructTypes[Idx]; }
6060
61 DenseSet &getVisitedMetadata() { return VisitedMetadata; }
62
6163 private:
6264 /// incorporateType - This method adds the type to the list of used
6365 /// structures if it's not in there already.
13421342 else
13431343 IdentifiedStructTypes.addNonOpaque(Ty);
13441344 }
1345 // Self-map metadatas in the destination module. This is needed when
1346 // DebugTypeODRUniquing is enabled on the LLVMContext, since metadata in the
1347 // destination module may be reached from the source module.
1348 for (auto *MD : StructTypes.getVisitedMetadata()) {
1349 SharedMDs[MD].reset(const_cast(MD));
1350 }
13451351 }
13461352
13471353 Error IRMover::move(
0 ; ModuleID = 'test/ThinLTO/X86/Inputs/crash_debuginfo.ll'
1 source_filename = "src.bc"
2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-apple-macosx10.7.0"
4
5 %another_type = type { i32 }
6
7 define void @bar(i32 %arg) {
8 %tmp = add i32 %arg, 0, !dbg !7
9 unreachable
10 }
11
12 !llvm.dbg.cu = !{!0}
13 !llvm.module.flags = !{!6}
14
15 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "Apple LLVM version 8.0.0 (clang-800.0.25.1)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !3, imports: !2)
16 !1 = !DIFile(filename: "2.cpp", directory: "some_dir")
17 !2 = !{}
18 !3 = !{!4}
19 !4 = distinct !DIGlobalVariable(name: "a_global", linkageName: "a_global", scope: null, line: 52, type: !5, isLocal: true, isDefinition: true, variable: %another_type** undef)
20 !5 = !DISubroutineType(types: !2)
21 !6 = !{i32 2, !"Debug Info Version", i32 3}
22 !7 = distinct !DILocation(line: 728, column: 71, scope: !8, inlinedAt: !14)
23 !8 = distinct !DISubprogram(name: "baz", linkageName: "baz", scope: !9, file: !1, line: 726, type: !5, isLocal: false, isDefinition: true, scopeLine: 727, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !10, variables: !11)
24 !9 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "some_other_class", scope: !1, file: !1, line: 197, size: 192, align: 64, elements: !2, templateParams: !2, identifier: "some_other_class")
25 !10 = !DISubprogram(name: "baz", linkageName: "baz", scope: !9, file: !1, line: 726, type: !5, isLocal: false, isDefinition: false, scopeLine: 726, flags: DIFlagPrototyped, isOptimized: true)
26 !11 = !{!12}
27 !12 = !DILocalVariable(name: "caster", scope: !8, file: !1, line: 728, type: !13)
28 !13 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !8, file: !1, line: 728, size: 64, align: 64, elements: !2, identifier: "someclass")
29 !14 = distinct !DILocation(line: 795, column: 16, scope: !15)
30 !15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 794, column: 7)
31 !16 = distinct !DISubprogram(name: "operator()", linkageName: "some_special_function", scope: null, file: !1, line: 783, type: !5, isLocal: true, isDefinition: true, scopeLine: 784, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !17, variables: !2)
32 !17 = !DISubprogram(name: "operator()", linkageName: "some_special_function", scope: null, file: !1, line: 783, type: !5, isLocal: false, isDefinition: false, scopeLine: 783, flags: DIFlagPrototyped, isOptimized: true)
0 ; RUN: opt -module-summary -o %t-dst.bc %s
1 ; RUN: opt -module-summary -o %t-src.bc %p/Inputs/crash_debuginfo.ll
2 ; RUN: llvm-lto -thinlto -o %t-index %t-dst.bc %t-src.bc
3 ; RUN: opt -function-import -inline -summary-file %t-index.thinlto.bc %t-dst.bc -o %t.out
4 ; RUN: llvm-nm %t.out | FileCheck %s
5
6 ; Verify that we import bar and inline it. It use to crash importing due to ODR type uniquing
7 ; CHECK-NOT: bar
8 ; CHECK: foo
9 ; CHECK-NOT: bar
10
11 ; ModuleID = 'test/ThinLTO/X86/crash_debuginfo.ll'
12 source_filename = "test/ThinLTO/X86/crash_debuginfo.ll"
13 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-apple-macosx10.7.0"
15
16 %some_type = type { i32 }
17
18 define void @foo(i32 %arg) {
19 call void @bar(i32 %arg), !dbg !7
20 unreachable
21 }
22
23 declare void @bar(i32)
24
25 !llvm.dbg.cu = !{!0}
26 !llvm.module.flags = !{!6}
27
28 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "Apple LLVM version 8.0.0 (clang-800.0.24.1)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2)
29 !1 = !DIFile(filename: "1.cpp", directory: "/another_dir")
30 !2 = !{!3}
31 !3 = distinct !DIGlobalVariable(name: "_", linkageName: "some_global", scope: null, file: !1, line: 20, type: !4, isLocal: true, isDefinition: true, variable: %some_type* undef)
32 !4 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "slice_nil", file: !1, line: 13, size: 64, align: 64, elements: !5, identifier: "_ZTSN5boost6python3api9slice_nilE")
33 !5 = !{}
34 !6 = !{i32 2, !"Debug Info Version", i32 3}
35 !7 = distinct !DILocation(line: 728, column: 71, scope: !8, inlinedAt: !15)
36 !8 = distinct !DISubprogram(name: "baz", linkageName: "baz", scope: !9, file: !1, line: 726, type: !10, isLocal: false, isDefinition: true, scopeLine: 727, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !11, variables: !12)
37 !9 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "some_other_class", file: !1, line: 197, size: 192, align: 64, elements: !5, templateParams: !5, identifier: "some_other_class")
38 !10 = !DISubroutineType(types: !5)
39 !11 = !DISubprogram(name: "baz", linkageName: "baz", scope: !9, file: !1, line: 726, type: !10, isLocal: false, isDefinition: false, scopeLine: 726, flags: DIFlagPrototyped, isOptimized: true)
40 !12 = !{!13}
41 !13 = !DILocalVariable(name: "caster", scope: !8, file: !1, line: 728, type: !14)
42 !14 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !8, file: !1, line: 728, size: 64, align: 64, elements: !5, identifier: "someclass")
43 !15 = distinct !DILocation(line: 87, column: 9, scope: !16)
44 !16 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !9, line: 73, type: !10, isLocal: false, isDefinition: true, scopeLine: 74, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !17, variables: !5)
45 !17 = !DISubprogram(name: "foo", linkageName: "foo", scope: !9, file: !1, line: 83, type: !10, isLocal: false, isDefinition: false, scopeLine: 83, flags: DIFlagPrototyped, isOptimized: true)