1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
# RUN: llc -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
# Test the extension of debug ranges from predecessors.
# Generated from the source file LiveDebugValues.c:
# #include <stdio.h>
# int m;
# extern int inc(int n);
# extern int change(int n);
# extern int modify(int n);
# int main(int argc, char **argv) {
# int n;
# if (argc != 2)
# n = 2;
# else
# n = atoi(argv[1]);
# n = change(n);
# if (n > 10) {
# m = modify(n);
# m = m + n; // var `m' doesn't has a dbg.value
# }
# else
# m = inc(n); // var `m' doesn't has a dbg.value
# printf("m(main): %d\n", m);
# return 0;
# }
# with clang -g -O3 -c -emit-llvm LiveDebugValues.c -S -o live-debug-values.ll
# then llc -stop-after stackmap-liveness live-debug-values.ll -o /dev/null > live-debug-values.mir
# This case will also produce multiple locations but only the debug range
# extension is tested here. This test case is tested with DWARF information under
# llvm/test/DebugInfo/live-debug-values.ll and present here for testing under
# MIR->MIR serialization.
# DBG_VALUE for variable "n" is extended into %bb.5 from its predecessors %bb.3
# and %bb.4.
# CHECK: ![[N_VAR:[0-9]+]] = !DILocalVariable(name: "n",{{.*}})
#
# CHECK: bb.5.if.end.7:
# CHECK: DBG_VALUE $ebx, $noreg, ![[N_VAR]], !DIExpression()
--- |
; ModuleID = 'live-debug-values.ll'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@m = common global i32 0, align 4, !dbg !16
@.str = private unnamed_addr constant [13 x i8] c"m(main): %d\0A\00", align 1
; Function Attrs: nounwind uwtable
define i32 @main(i32 %argc, i8** nocapture readonly %argv) #0 !dbg !4 {
entry:
tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !12, metadata !20), !dbg !21
tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !13, metadata !20), !dbg !22
%cmp = icmp eq i32 %argc, 2, !dbg !24
br i1 %cmp, label %if.else, label %if.end, !dbg !26
if.else: ; preds = %entry
%arrayidx = getelementptr inbounds i8*, i8** %argv, i64 1, !dbg !27
%0 = load i8*, i8** %arrayidx, align 8, !dbg !27, !tbaa !28
%call = tail call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %0) #4, !dbg !32
tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !14, metadata !20), !dbg !33
br label %if.end
if.end: ; preds = %if.else, %entry
%n.0 = phi i32 [ %call, %if.else ], [ 2, %entry ]
%call1 = tail call i32 @change(i32 %n.0) #4, !dbg !34
tail call void @llvm.dbg.value(metadata i32 %call1, i64 0, metadata !14, metadata !20), !dbg !33
%cmp2 = icmp sgt i32 %call1, 10, !dbg !35
br i1 %cmp2, label %if.then.3, label %if.else.5, !dbg !37
if.then.3: ; preds = %if.end
%call4 = tail call i32 @modify(i32 %call1) #4, !dbg !38
%add = add nsw i32 %call4, %call1, !dbg !40
br label %if.end.7, !dbg !41
if.else.5: ; preds = %if.end
%call6 = tail call i32 @inc(i32 %call1) #4, !dbg !42
br label %if.end.7
if.end.7: ; preds = %if.else.5, %if.then.3
%storemerge = phi i32 [ %call6, %if.else.5 ], [ %add, %if.then.3 ]
store i32 %storemerge, i32* @m, align 4, !dbg !43, !tbaa !44
%call8 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %storemerge) #4, !dbg !46
ret i32 0, !dbg !47
}
declare i32 @atoi(...) #1
declare i32 @change(i32) #1
declare i32 @modify(i32) #1
declare i32 @inc(i32) #1
; Function Attrs: nounwind
declare i32 @printf(i8* nocapture readonly, ...) #2
; Function Attrs: nounwind readnone
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind }
attributes #2 = { nounwind }
attributes #3 = { nounwind readnone }
attributes #4 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!17, !18}
!llvm.ident = !{!19}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 253049) ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !15)
!1 = !DIFile(filename: "LiveDebugValues.c", directory: "/home/vt/julia/test/tvvikram")
!2 = !{}
!4 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
!5 = !DISubroutineType(types: !6)
!6 = !{!7, !7, !8}
!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, align: 64)
!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
!10 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
!11 = !{!12, !13, !14}
!12 = !DILocalVariable(name: "argc", arg: 1, scope: !4, file: !1, line: 6, type: !7)
!13 = !DILocalVariable(name: "argv", arg: 2, scope: !4, file: !1, line: 6, type: !8)
!14 = !DILocalVariable(name: "n", scope: !4, file: !1, line: 7, type: !7)
!15 = !{!16}
!16 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "m", scope: !0, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true), expr: !DIExpression())
!17 = !{i32 2, !"Dwarf Version", i32 4}
!18 = !{i32 2, !"Debug Info Version", i32 3}
!19 = !{!"clang version 3.8.0 (trunk 253049)"}
!20 = !DIExpression()
!21 = !DILocation(line: 6, column: 14, scope: !4)
!22 = !DILocation(line: 6, column: 27, scope: !23)
!23 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 1)
!24 = !DILocation(line: 8, column: 12, scope: !25)
!25 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
!26 = !DILocation(line: 8, column: 7, scope: !4)
!27 = !DILocation(line: 11, column: 14, scope: !25)
!28 = !{!29, !29, i64 0}
!29 = !{!"any pointer", !30, i64 0}
!30 = !{!"omnipotent char", !31, i64 0}
!31 = !{!"Simple C/C++ TBAA"}
!32 = !DILocation(line: 11, column: 9, scope: !25)
!33 = !DILocation(line: 7, column: 7, scope: !23)
!34 = !DILocation(line: 12, column: 7, scope: !4)
!35 = !DILocation(line: 13, column: 9, scope: !36)
!36 = distinct !DILexicalBlock(scope: !4, file: !1, line: 13, column: 7)
!37 = !DILocation(line: 13, column: 7, scope: !4)
!38 = !DILocation(line: 14, column: 9, scope: !39)
!39 = distinct !DILexicalBlock(scope: !36, file: !1, line: 13, column: 15)
!40 = !DILocation(line: 15, column: 11, scope: !39)
!41 = !DILocation(line: 16, column: 3, scope: !39)
!42 = !DILocation(line: 18, column: 9, scope: !36)
!43 = !DILocation(line: 15, column: 7, scope: !39)
!44 = !{!45, !45, i64 0}
!45 = !{!"int", !30, i64 0}
!46 = !DILocation(line: 19, column: 3, scope: !4)
!47 = !DILocation(line: 20, column: 3, scope: !4)
...
---
name: main
alignment: 16
exposesReturnsTwice: false
tracksRegLiveness: true
liveins:
- { reg: '$edi' }
- { reg: '$rsi' }
calleeSavedRegisters: [ '$bh', '$bl', '$bp', '$bpl', '$bx', '$ebp', '$ebx',
'$rbp', '$rbx', '$r12', '$r13', '$r14', '$r15',
'$r12b', '$r13b', '$r14b', '$r15b', '$r12d', '$r13d',
'$r14d', '$r15d', '$r12w', '$r13w', '$r14w', '$r15w' ]
frameInfo:
isFrameAddressTaken: false
isReturnAddressTaken: false
hasStackMap: false
hasPatchPoint: false
stackSize: 8
offsetAdjustment: 0
maxAlignment: 0
adjustsStack: true
hasCalls: true
maxCallFrameSize: 0
hasOpaqueSPAdjustment: false
hasVAStart: false
hasMustTailInVarArgFunc: false
fixedStack:
- { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$rbx' }
body: |
bb.0.entry:
successors: %bb.1.if.else(16), %bb.2.if.end(16)
liveins: $edi, $rsi, $rbx
frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
CFI_INSTRUCTION def_cfa_offset 16
CFI_INSTRUCTION offset $rbx, -16
DBG_VALUE $edi, _, !12, !20, debug-location !21
DBG_VALUE $rsi, _, !13, !20, debug-location !22
$eax = MOV32rr $edi
DBG_VALUE $eax, _, !12, !20, debug-location !21
$edi = MOV32ri 2
CMP32ri8 killed $eax, 2, implicit-def $eflags, debug-location !26
JCC_1 %bb.2.if.end, 5, implicit $eflags
bb.1.if.else:
successors: %bb.2.if.end(0)
liveins: $rsi
DBG_VALUE $rsi, _, !13, !20, debug-location !22
$rdi = MOV64rm killed $rsi, 1, _, 8, _, debug-location !27 :: (load (s64) from %ir.arrayidx, !tbaa !28)
dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !32
CALL64pcrel32 @atoi, csr_64, implicit $rsp, implicit $rdi, implicit $al, implicit-def $rsp, implicit-def $eax, debug-location !32
$edi = MOV32rr $eax, debug-location !32
DBG_VALUE $edi, _, !14, !20, debug-location !33
bb.2.if.end:
successors: %bb.3.if.then.3(16), %bb.4.if.else.5(16)
liveins: $edi
CALL64pcrel32 @change, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, implicit-def $eax, debug-location !34
$ebx = MOV32rr $eax, debug-location !34
DBG_VALUE $ebx, _, !14, !20, debug-location !33
CMP32ri8 $ebx, 11, implicit-def $eflags, debug-location !37
JCC_1 %bb.4.if.else.5, 12, implicit killed $eflags, debug-location !37
bb.3.if.then.3:
successors: %bb.5.if.end.7(0)
liveins: $ebx
DBG_VALUE $ebx, _, !14, !20, debug-location !33
$edi = MOV32rr $ebx, debug-location !38
CALL64pcrel32 @modify, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, implicit-def $eax, debug-location !38
$ecx = MOV32rr $eax, debug-location !38
$ecx = ADD32rr killed $ecx, killed $ebx, implicit-def dead $eflags, debug-location !40
JMP_1 %bb.5.if.end.7
bb.4.if.else.5:
successors: %bb.5.if.end.7(0)
liveins: $ebx
DBG_VALUE $ebx, _, !14, !20, debug-location !33
$edi = MOV32rr killed $ebx, debug-location !42
CALL64pcrel32 @inc, csr_64, implicit $rsp, implicit $edi, implicit-def $rsp, implicit-def $eax, debug-location !42
$ecx = MOV32rr $eax, debug-location !42
bb.5.if.end.7:
liveins: $ecx
MOV32mr $rip, 1, _, @m, _, $ecx, debug-location !43 :: (store (s32) into @m, !tbaa !44)
dead undef $edi = MOV32ri @.str, implicit-def $rdi, debug-location !46
dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !47
$esi = MOV32rr killed $ecx, debug-location !46
CALL64pcrel32 @printf, csr_64, implicit $rsp, implicit $rdi, implicit $esi, implicit $al, implicit-def $rsp, implicit-def dead $eax, debug-location !46
$eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !47
$rbx = POP64r implicit-def $rsp, implicit $rsp, debug-location !47
RET64 $eax, debug-location !47
...
|