blob: a6f3db910f5212aafa80f33e9b5f035fea71f573 [file] [log] [blame]
Ulrich Weigand08bd6152013-05-06 16:18:29 +00001; RUN: llc -mtriple=s390x-linux-gnu -disable-fp-elim < %s | FileCheck %s
David Blaikie2f753512014-05-23 21:11:46 +00002; RUN: llc -mtriple=s390x-linux-gnu -disable-fp-elim -filetype=obj < %s \
3; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck --check-prefix=DEBUG %s
Ulrich Weigand08bd6152013-05-06 16:18:29 +00004;
5; This is a regression test making sure the location of variables is correct in
6; debugging information, even if they're addressed via the frame pointer.
Richard Sandiford9b9e0572014-01-13 15:42:16 +00007; Originally a copy of the AArch64 test, commandeered for SystemZ.
Ulrich Weigand08bd6152013-05-06 16:18:29 +00008;
9; First make sure main_arr is where we expect it: %r11 + 164
10;
11; CHECK: main:
12; CHECK: aghi %r15, -568
Richard Sandiford891a7e72013-06-27 09:42:10 +000013; CHECK: la %r2, 164(%r11)
Ulrich Weigand08bd6152013-05-06 16:18:29 +000014; CHECK: brasl %r14, populate_array@PLT
David Blaikie2f753512014-05-23 21:11:46 +000015
16; DEBUG: DW_TAG_variable
David Blaikie2f753512014-05-23 21:11:46 +000017; Rather hard-coded, but 0x91 => DW_OP_fbreg and 0xa401 is SLEB128 encoded 164.
18; DEBUG-NOT: DW_TAG
19; DEBUG: DW_AT_location {{.*}}(<0x3> 91 a4 01 )
David Blaikieeb1a2722014-06-13 22:18:23 +000020; DEBUG-NOT: DW_TAG
21; DEBUG: DW_AT_name {{.*}} "main_arr"
Ulrich Weigand08bd6152013-05-06 16:18:29 +000022
23
24@.str = private unnamed_addr constant [13 x i8] c"Total is %d\0A\00", align 2
25
26declare void @populate_array(i32*, i32) nounwind
27
Adrian Prantl87b7eb92014-10-01 18:55:02 +000028declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
Ulrich Weigand08bd6152013-05-06 16:18:29 +000029
30declare i32 @sum_array(i32*, i32) nounwind
31
32define i32 @main() nounwind {
33entry:
34 %retval = alloca i32, align 4
35 %main_arr = alloca [100 x i32], align 4
36 %val = alloca i32, align 4
Richard Sandiford9b9e0572014-01-13 15:42:16 +000037 store volatile i32 0, i32* %retval
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000038 call void @llvm.dbg.declare(metadata [100 x i32]* %main_arr, metadata !17, metadata !MDExpression()), !dbg !22
39 call void @llvm.dbg.declare(metadata i32* %val, metadata !23, metadata !MDExpression()), !dbg !24
David Blaikie79e6c742015-02-27 19:29:02 +000040 %arraydecay = getelementptr inbounds [100 x i32], [100 x i32]* %main_arr, i32 0, i32 0, !dbg !25
Ulrich Weigand08bd6152013-05-06 16:18:29 +000041 call void @populate_array(i32* %arraydecay, i32 100), !dbg !25
David Blaikie79e6c742015-02-27 19:29:02 +000042 %arraydecay1 = getelementptr inbounds [100 x i32], [100 x i32]* %main_arr, i32 0, i32 0, !dbg !26
Ulrich Weigand08bd6152013-05-06 16:18:29 +000043 %call = call i32 @sum_array(i32* %arraydecay1, i32 100), !dbg !26
44 store i32 %call, i32* %val, align 4, !dbg !26
David Blaikiea79ac142015-02-27 21:17:42 +000045 %0 = load i32, i32* %val, align 4, !dbg !27
Ulrich Weigand08bd6152013-05-06 16:18:29 +000046 %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0), i32 %0), !dbg !27
47 ret i32 0, !dbg !28
48}
49
50declare i32 @printf(i8*, ...)
51
52!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000053!llvm.module.flags = !{!30}
Ulrich Weigand08bd6152013-05-06 16:18:29 +000054
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000055!0 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang version 3.2 ", isOptimized: false, emissionKind: 0, file: !29, enums: !1, retainedTypes: !1, subprograms: !3, globals: !1, imports: !1)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000056!1 = !{}
57!3 = !{!5, !11, !14}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000058!5 = !MDSubprogram(name: "populate_array", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !29, scope: !6, type: !7, function: void (i32*, i32)* @populate_array, variables: !1)
59!6 = !MDFile(filename: "simple.c", directory: "/home/timnor01/a64-trunk/build")
60!7 = !MDSubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000061!8 = !{null, !9, !10}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000062!9 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !10)
63!10 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
64!11 = !MDSubprogram(name: "sum_array", line: 9, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 9, file: !29, scope: !6, type: !12, function: i32 (i32*, i32)* @sum_array, variables: !1)
65!12 = !MDSubroutineType(types: !13)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000066!13 = !{!10, !9, !10}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000067!14 = !MDSubprogram(name: "main", line: 18, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 18, file: !29, scope: !6, type: !15, function: i32 ()* @main, variables: !1)
68!15 = !MDSubroutineType(types: !16)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000069!16 = !{!10}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000070!17 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "main_arr", line: 19, scope: !18, file: !6, type: !19)
71!18 = distinct !MDLexicalBlock(line: 18, column: 16, file: !29, scope: !14)
72!19 = !MDCompositeType(tag: DW_TAG_array_type, size: 3200, align: 32, baseType: !10, elements: !20)
73!20 = !MDSubrange(count: 99)
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +000074!22 = !MDLocation(line: 19, column: 7, scope: !18)
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000075!23 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "val", line: 20, scope: !18, file: !6, type: !10)
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +000076!24 = !MDLocation(line: 20, column: 7, scope: !18)
77!25 = !MDLocation(line: 22, column: 3, scope: !18)
78!26 = !MDLocation(line: 23, column: 9, scope: !18)
79!27 = !MDLocation(line: 24, column: 3, scope: !18)
80!28 = !MDLocation(line: 26, column: 3, scope: !18)
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000081!29 = !MDFile(filename: "simple.c", directory: "/home/timnor01/a64-trunk/build")
82!30 = !{i32 1, !"Debug Info Version", i32 3}