87 lines · plain
1; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s2 3; Testing that two distinct (distinct by writing them in separate files, while4; still fulfilling C++'s ODR by having identical token sequences) functions,5; linked under LTO, get plausible debug info (and don't crash).6 7; Built from source:8; $ clang++ a.cpp b.cpp -g -c -emit-llvm9; $ llvm-link a.bc b.bc -o ab.bc10 11; This change is intended to tickle a case where the subprogram MDNode12; associated with the llvm::Function will differ from the subprogram13; referenced by the DbgLocs in the function.14 15; $ sed -ie "s/!12, !0/!0, !12/" ab.ll16; $ cat a.cpp17; inline int func(int i) {18; return i * 2;19; }20; int (*x)(int) = &func;21; $ cat b.cpp22; inline int func(int i) {23; return i * 2;24; }25; int (*y)(int) = &func;26 27; The DISubprogram should show up in compile unit a.28; CHECK: DW_TAG_compile_unit29; CHECK-NOT: DW_TAG30; CHECK: DW_AT_name ("b.cpp")31; CHECK-NOT: DW_TAG_subprogram32 33; CHECK: DW_TAG_compile_unit34; CHECK-NOT: DW_TAG35; CHECK: DW_AT_name ("a.cpp")36; CHECK: DW_AT_name ("func")37 38source_filename = "test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll"39 40@x = global ptr @_Z4funci, align 8, !dbg !041@y = global ptr @_Z4funci, align 8, !dbg !742 43; Function Attrs: inlinehint nounwind uwtable44define linkonce_odr i32 @_Z4funci(i32 %i) #0 !dbg !18 {45 %1 = alloca i32, align 446 store i32 %i, ptr %1, align 447 call void @llvm.dbg.declare(metadata ptr %1, metadata !19, metadata !20), !dbg !2148 %2 = load i32, ptr %1, align 4, !dbg !2249 %3 = mul nsw i32 %2, 2, !dbg !2250 ret i32 %3, !dbg !2251}52 53; Function Attrs: nounwind readnone54declare void @llvm.dbg.declare(metadata, metadata, metadata) #155 56attributes #0 = { inlinehint nounwind uwtable }57attributes #1 = { nounwind readnone }58 59!llvm.dbg.cu = !{!10, !13}60!llvm.module.flags = !{!15, !16}61!llvm.ident = !{!17, !17}62 63!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())64!1 = !DIGlobalVariable(name: "x", scope: null, file: !2, line: 4, type: !3, isLocal: false, isDefinition: true)65!2 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo")66!3 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64)67!4 = !DISubroutineType(types: !5)68!5 = !{!6, !6}69!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)70!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())71!8 = !DIGlobalVariable(name: "y", scope: null, file: !9, line: 4, type: !3, isLocal: false, isDefinition: true)72!9 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo")73!10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !9, producer: "clang version 3.5.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !12, imports: !11)74!11 = !{}75!12 = !{!7}76!13 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.5.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !14, imports: !11)77!14 = !{!0}78!15 = !{i32 2, !"Dwarf Version", i32 4}79!16 = !{i32 1, !"Debug Info Version", i32 3}80!17 = !{!"clang version 3.5.0 "}81!18 = distinct !DISubprogram(name: "func", linkageName: "_Z4funci", scope: !2, file: !2, line: 1, type: !4, isLocal: false, isDefinition: true, scopeLine: 1, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !13, retainedNodes: !11)82!19 = !DILocalVariable(name: "i", arg: 1, scope: !18, file: !2, line: 1, type: !6)83!20 = !DIExpression()84!21 = !DILocation(line: 1, scope: !18)85!22 = !DILocation(line: 2, scope: !18)86 87