brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · cfc8a9f Raw
78 lines · plain
1; RUN: opt -passes=mem2reg %s -S -o - | FileCheck %s2 3;; Check that mem2reg removes dbg.value(%param.addr, DIExpression(DW_OP_deref...))4;; when promoting the alloca %param.addr.5;;6;; $ clang inlining.c -O2 -g -emit-llvm -S -o tmp.ll -Xclang -disable-llvm-passes7;; $ opt tmp.ll -o - -instcombine -inline -S8;; $ cat inlining.c9;; int g;10;; __attribute__((__always_inline__))11;; static void use(int* p) {12;;   g = *p;13;; }14;;15;; __attribute__((__noinline__))16;; void fun(int param) {17;;   use(&param);18;; }19 20; CHECK: define dso_local void @fun(i32 %param)21; CHECK-NEXT: entry:22; CHECK-NEXT: #dbg_value(i32 %param, ![[PARAM:[0-9]+]], !DIExpression(),23; CHECK-NEXT: #dbg_value(i32 %param, ![[PARAM]], !DIExpression(),24; CHECK: ![[PARAM]] = !DILocalVariable(name: "param",25 26@g = dso_local global i32 0, align 4, !dbg !027 28define dso_local void @fun(i32 %param) !dbg !12 {29entry:30  %param.addr = alloca i32, align 431  call void @llvm.dbg.value(metadata i32 %param, metadata !16, metadata !DIExpression()), !dbg !1732  store i32 %param, ptr %param.addr, align 433  call void @llvm.dbg.value(metadata ptr %param.addr, metadata !16, metadata !DIExpression(DW_OP_deref)), !dbg !1734  call void @llvm.dbg.value(metadata ptr %param.addr, metadata !22, metadata !DIExpression()), !dbg !2835  call void @llvm.dbg.value(metadata ptr %param.addr, metadata !22, metadata !DIExpression()), !dbg !2836  %0 = load i32, ptr %param.addr, align 4, !dbg !3037  store i32 %0, ptr @g, align 4, !dbg !3138  ret void, !dbg !3239}40 41declare void @llvm.dbg.value(metadata, metadata, metadata)42 43!llvm.dbg.cu = !{!2}44!llvm.module.flags = !{!8, !9, !10}45!llvm.ident = !{!11}46 47!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())48!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !6, line: 8, type: !7, isLocal: false, isDefinition: true)49!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)50!3 = !DIFile(filename: "inlining.c", directory: "/")51!4 = !{}52!5 = !{!0}53!6 = !DIFile(filename: "inlining.c", directory: "/")54!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)55!8 = !{i32 7, !"Dwarf Version", i32 4}56!9 = !{i32 2, !"Debug Info Version", i32 3}57!10 = !{i32 1, !"wchar_size", i32 4}58!11 = !{!"clang version 12.0.0"}59!12 = distinct !DISubprogram(name: "fun", scope: !6, file: !6, line: 15, type: !13, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !15)60!13 = !DISubroutineType(types: !14)61!14 = !{null, !7}62!15 = !{!16}63!16 = !DILocalVariable(name: "param", arg: 1, scope: !12, file: !6, line: 15, type: !7)64!17 = !DILocation(line: 0, scope: !12)65!22 = !DILocalVariable(name: "p", arg: 1, scope: !23, file: !6, line: 10, type: !26)66!23 = distinct !DISubprogram(name: "use", scope: !6, file: !6, line: 10, type: !24, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !27)67!24 = !DISubroutineType(types: !25)68!25 = !{null, !26}69!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)70!27 = !{!22}71!28 = !DILocation(line: 0, scope: !23, inlinedAt: !29)72!29 = distinct !DILocation(line: 16, column: 3, scope: !12)73!30 = !DILocation(line: 11, column: 7, scope: !23, inlinedAt: !29)74!31 = !DILocation(line: 11, column: 5, scope: !23, inlinedAt: !29)75!32 = !DILocation(line: 17, column: 1, scope: !12)76!34 = !DISubroutineType(types: !35)77!35 = !{!7}78