brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.5 KiB · 3174fc3 Raw
269 lines · plain
1; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -debug-info - | FileCheck %s2 3; This isn't a very pretty test case - I imagine there might be other ways to4; tickle the optimizers into producing the desired code, but I haven't found5; them.6 7; The issue is when a function is inlined into itself, the inlined argument8; accidentally overwrote the concrete argument and was lost.9 10; IR generated from the following source compiled with clang -g:11; void fn1(ptr);12; void fn2(int, int, int, int);13; void fn3();14; void fn8();15; struct C {16;   int b;17;   void m_fn2() {18;     fn8();19;     if (b) fn2(0, 0, 0, 0);20;     fn3();21;   }22; };23; C *x;24; inline void fn7() {}25; void fn6() {26;   fn8();27;   x->m_fn2();28;   fn7();29; }30; void fn3() { fn6(); }31; void fn4() { x->m_fn2(); }32; void fn5() { x->m_fn2(); }33 34; The definition of C and declaration of C::m_fn235; CHECK: DW_TAG_structure_type36; CHECK-NOT: {{DW_TAG|NULL}}37; CHECK: DW_TAG_member38; CHECK-NOT: {{DW_TAG|NULL}}39; CHECK: [[M_FN2_DECL:.*]]: DW_TAG_subprogram40; CHECK-NOT: DW_TAG41; CHECK:     DW_AT_name ("m_fn2")42; CHECK-NOT: {{DW_TAG|NULL}}43; CHECK:     DW_TAG_formal_parameter44 45; The abstract definition of C::m_fn246; CHECK: [[M_FN2_ABS_DEF:.*]]: DW_TAG_subprogram47; CHECK-NOT: DW_TAG48; CHECK:   DW_AT_specification {{.*}}[[M_FN2_DECL]]49; CHECK-NOT: DW_TAG50; CHECK:   DW_AT_inline51; CHECK-NOT: {{DW_TAG|NULL}}52; CHECK: [[M_FN2_THIS_ABS_DEF:.*]]:   DW_TAG_formal_parameter53; CHECK-NOT: DW_TAG54; CHECK:     DW_AT_name ("this")55 56; Skip some other functions57; CHECK: DW_TAG_subprogram58; CHECK: DW_TAG_subprogram59; CHECK: DW_TAG_subprogram60 61; The concrete definition of C::m_fn262; CHECK: DW_TAG_subprogram63; CHECK-NOT: DW_TAG64; CHECK:   DW_AT_abstract_origin {{.*}}[[M_FN2_ABS_DEF]]65; CHECK-NOT: {{DW_TAG|NULL}}66; CHECK:   DW_TAG_formal_parameter67; CHECK-NOT: DW_TAG68; CHECK:     DW_AT_abstract_origin {{.*}}[[M_FN2_THIS_ABS_DEF]]69; CHECK-NOT: {{DW_TAG|NULL}}70; Inlined fn3:71; CHECK:     DW_TAG_inlined_subroutine72; CHECK-NOT: {{DW_TAG|NULL}}73; Inlined fn6:74; CHECK:       DW_TAG_inlined_subroutine75; CHECK-NOT: {{DW_TAG|NULL}}76; Inlined C::m_fn2:77; CHECK:         DW_TAG_inlined_subroutine78; CHECK-NOT: DW_TAG79; CHECK:           DW_AT_abstract_origin {{.*}}[[M_FN2_ABS_DEF]]80; CHECK-NOT: {{DW_TAG|NULL}}81; CHECK:           DW_TAG_formal_parameter82; CHECK-NOT: DW_TAG83; CHECK:              DW_AT_abstract_origin {{.*}}[[M_FN2_THIS_ABS_DEF]]84 85source_filename = "test/DebugInfo/Generic/recursive_inlining.ll"86 87%struct.C = type { i32 }88 89@x = global ptr null, align 8, !dbg !090 91; Function Attrs: nounwind92define void @_Z3fn6v() #0 !dbg !20 {93entry:94  tail call void @_Z3fn8v() #3, !dbg !2395  %0 = load ptr, ptr @x, align 8, !dbg !24, !tbaa !2596  tail call void @llvm.dbg.value(metadata ptr %0, metadata !29, metadata !32) #3, !dbg !3397  tail call void @_Z3fn8v() #3, !dbg !3498  %1 = load i32, ptr %0, align 4, !dbg !35, !tbaa !3799  %tobool.i = icmp eq i32 %1, 0, !dbg !35100  br i1 %tobool.i, label %_ZN1C5m_fn2Ev.exit, label %if.then.i, !dbg !35101 102if.then.i:                                        ; preds = %entry103  tail call void @_Z3fn2iiii(i32 0, i32 0, i32 0, i32 0) #3, !dbg !40104  br label %_ZN1C5m_fn2Ev.exit, !dbg !40105 106_ZN1C5m_fn2Ev.exit:                               ; preds = %if.then.i, %entry107  tail call void @_Z3fn3v() #3, !dbg !42108  ret void, !dbg !43109}110 111declare void @_Z3fn8v() #1112 113; Function Attrs: nounwind114 115define linkonce_odr void @_ZN1C5m_fn2Ev(ptr nocapture readonly %this) #0 align 2 !dbg !30 {116entry:117  tail call void @llvm.dbg.value(metadata ptr %this, metadata !29, metadata !32), !dbg !44118  tail call void @_Z3fn8v() #3, !dbg !45119  %0 = load i32, ptr %this, align 4, !dbg !46, !tbaa !37120  %tobool = icmp eq i32 %0, 0, !dbg !46121  br i1 %tobool, label %if.end, label %if.then, !dbg !46122 123if.then:                                          ; preds = %entry124  tail call void @_Z3fn2iiii(i32 0, i32 0, i32 0, i32 0) #3, !dbg !47125  br label %if.end, !dbg !47126 127if.end:                                           ; preds = %if.then, %entry128  tail call void @_Z3fn8v() #3, !dbg !48129  %1 = load ptr, ptr @x, align 8, !dbg !52, !tbaa !25130  tail call void @llvm.dbg.value(metadata ptr %1, metadata !29, metadata !32) #3, !dbg !53131  tail call void @_Z3fn8v() #3, !dbg !54132  %2 = load i32, ptr %1, align 4, !dbg !55, !tbaa !37133  %tobool.i.i = icmp eq i32 %2, 0, !dbg !55134  br i1 %tobool.i.i, label %_Z3fn6v.exit, label %if.then.i.i, !dbg !55135 136if.then.i.i:                                      ; preds = %if.end137 138  tail call void @_Z3fn2iiii(i32 0, i32 0, i32 0, i32 0) #3, !dbg !56139  br label %_Z3fn6v.exit, !dbg !56140 141_Z3fn6v.exit:                                     ; preds = %if.then.i.i, %if.end142  tail call void @_Z3fn3v() #3, !dbg !57143  ret void, !dbg !58144}145 146; Function Attrs: nounwind147define void @_Z3fn3v() #0 !dbg !50 {148entry:149  br label %tailrecurse150 151tailrecurse:                                      ; preds = %tailrecurse.backedge, %entry152  tail call void @_Z3fn8v() #3, !dbg !59153  %0 = load ptr, ptr @x, align 8, !dbg !61, !tbaa !25154  tail call void @llvm.dbg.value(metadata ptr %0, metadata !29, metadata !32) #3, !dbg !62155  tail call void @_Z3fn8v() #3, !dbg !63156  %1 = load i32, ptr %0, align 4, !dbg !64, !tbaa !37157  %tobool.i.i = icmp eq i32 %1, 0, !dbg !64158  br i1 %tobool.i.i, label %tailrecurse.backedge, label %if.then.i.i, !dbg !64159 160tailrecurse.backedge:                             ; preds = %if.then.i.i, %tailrecurse161  br label %tailrecurse162 163if.then.i.i:                                      ; preds = %tailrecurse164  tail call void @_Z3fn2iiii(i32 0, i32 0, i32 0, i32 0) #3, !dbg !65165  br label %tailrecurse.backedge, !dbg !65166}167 168; Function Attrs: nounwind169define void @_Z3fn4v() #0 !dbg !66 {170entry:171  %0 = load ptr, ptr @x, align 8, !dbg !67, !tbaa !25172  tail call void @_ZN1C5m_fn2Ev(ptr %0), !dbg !67173  ret void, !dbg !67174}175 176; Function Attrs: nounwind177define void @_Z3fn5v() #0 !dbg !68 {178entry:179  %0 = load ptr, ptr @x, align 8, !dbg !69, !tbaa !25180  tail call void @_ZN1C5m_fn2Ev(ptr %0), !dbg !69181  ret void, !dbg !69182}183 184declare void @_Z3fn2iiii(i32, i32, i32, i32) #1185 186; Function Attrs: nounwind readnone187declare void @llvm.dbg.value(metadata, metadata, metadata) #2188 189attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "use-soft-float"="false" }190attributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "use-soft-float"="false" }191attributes #2 = { nounwind readnone }192attributes #3 = { nounwind }193 194!llvm.dbg.cu = !{!12}195!llvm.module.flags = !{!17, !18}196!llvm.ident = !{!19}197 198!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())199!1 = !DIGlobalVariable(name: "x", scope: null, file: !2, line: 13, type: !3, isLocal: false, isDefinition: true)200!2 = !DIFile(filename: "recursive_inlining.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch/missing_concrete_variable_on_darwin/reduce")201!3 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64)202!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !2, line: 5, size: 32, align: 32, elements: !5, identifier: "_ZTS1C")203!5 = !{!6, !8}204!6 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !4, file: !2, line: 6, baseType: !7, size: 32, align: 32)205!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)206!8 = !DISubprogram(name: "m_fn2", linkageName: "_ZN1C5m_fn2Ev", scope: !4, file: !2, line: 7, type: !9, isLocal: false, isDefinition: false, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true)207!9 = !DISubroutineType(types: !10)208!10 = !{null, !11}209!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)210!12 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !13, producer: "clang version 3.6.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !14, retainedTypes: !15, globals: !16, imports: !14)211!13 = !DIFile(filename: "<stdin>", directory: "/usr/local/google/home/blaikie/dev/scratch/missing_concrete_variable_on_darwin/reduce")212!14 = !{}213!15 = !{!4}214!16 = !{!0}215!17 = !{i32 2, !"Dwarf Version", i32 4}216!18 = !{i32 2, !"Debug Info Version", i32 3}217!19 = !{!"clang version 3.6.0 "}218!20 = distinct !DISubprogram(name: "fn6", linkageName: "_Z3fn6v", scope: !2, file: !2, line: 15, type: !21, isLocal: false, isDefinition: true, scopeLine: 15, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !12, retainedNodes: !14)219!21 = !DISubroutineType(types: !22)220!22 = !{null}221!23 = !DILocation(line: 16, scope: !20)222!24 = !DILocation(line: 17, scope: !20)223!25 = !{!26, !26, i64 0}224!26 = !{!"any pointer", !27, i64 0}225!27 = !{!"omnipotent char", !28, i64 0}226!28 = !{!"Simple C/C++ TBAA"}227!29 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !3, flags: DIFlagArtificial | DIFlagObjectPointer)228!30 = distinct !DISubprogram(name: "m_fn2", linkageName: "_ZN1C5m_fn2Ev", scope: !4, file: !2, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !12, declaration: !8, retainedNodes: !31)229!31 = !{!29}230!32 = !DIExpression()231!33 = !DILocation(line: 0, scope: !30, inlinedAt: !24)232!34 = !DILocation(line: 8, scope: !30, inlinedAt: !24)233!35 = !DILocation(line: 9, scope: !36, inlinedAt: !24)234!36 = distinct !DILexicalBlock(scope: !30, file: !2, line: 9)235!37 = !{!38, !39, i64 0}236!38 = !{!"struct", !39, i64 0}237!39 = !{!"int", !27, i64 0}238!40 = !DILocation(line: 9, scope: !41, inlinedAt: !24)239!41 = distinct !DILexicalBlock(scope: !36, file: !2, line: 9)240!42 = !DILocation(line: 10, scope: !30, inlinedAt: !24)241!43 = !DILocation(line: 19, scope: !20)242!44 = !DILocation(line: 0, scope: !30)243!45 = !DILocation(line: 8, scope: !30)244!46 = !DILocation(line: 9, scope: !36)245!47 = !DILocation(line: 9, scope: !41)246!48 = !DILocation(line: 16, scope: !20, inlinedAt: !49)247!49 = !DILocation(line: 20, scope: !50, inlinedAt: !51)248!50 = distinct !DISubprogram(name: "fn3", linkageName: "_Z3fn3v", scope: !2, file: !2, line: 20, type: !21, isLocal: false, isDefinition: true, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !12, retainedNodes: !14)249!51 = !DILocation(line: 10, scope: !30)250!52 = !DILocation(line: 17, scope: !20, inlinedAt: !49)251!53 = !DILocation(line: 0, scope: !30, inlinedAt: !52)252!54 = !DILocation(line: 8, scope: !30, inlinedAt: !52)253!55 = !DILocation(line: 9, scope: !36, inlinedAt: !52)254!56 = !DILocation(line: 9, scope: !41, inlinedAt: !52)255!57 = !DILocation(line: 10, scope: !30, inlinedAt: !52)256!58 = !DILocation(line: 11, scope: !30)257!59 = !DILocation(line: 16, scope: !20, inlinedAt: !60)258!60 = !DILocation(line: 20, scope: !50)259!61 = !DILocation(line: 17, scope: !20, inlinedAt: !60)260!62 = !DILocation(line: 0, scope: !30, inlinedAt: !61)261!63 = !DILocation(line: 8, scope: !30, inlinedAt: !61)262!64 = !DILocation(line: 9, scope: !36, inlinedAt: !61)263!65 = !DILocation(line: 9, scope: !41, inlinedAt: !61)264!66 = distinct !DISubprogram(name: "fn4", linkageName: "_Z3fn4v", scope: !2, file: !2, line: 21, type: !21, isLocal: false, isDefinition: true, scopeLine: 21, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !12, retainedNodes: !14)265!67 = !DILocation(line: 21, scope: !66)266!68 = distinct !DISubprogram(name: "fn5", linkageName: "_Z3fn5v", scope: !2, file: !2, line: 22, type: !21, isLocal: false, isDefinition: true, scopeLine: 22, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !12, retainedNodes: !14)267!69 = !DILocation(line: 22, scope: !68)268 269