| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 1 | ; RUN: opt %s -sroa -verify -S -o - | FileCheck %s |
| 2 | ; ModuleID = 'test.c' |
| 3 | ; Test that SROA updates the debug info correctly if an alloca was rewritten but |
| 4 | ; not partitioned into multiple allocas. |
| 5 | ; |
| Reid Kleckner | 6d35334 | 2017-08-23 20:31:27 +0000 | [diff] [blame] | 6 | ; CHECK: call void @llvm.dbg.value(metadata float %s.coerce, metadata ![[VAR:[0-9]+]], metadata !DIExpression()) |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 7 | ; CHECK: ![[VAR]] = !DILocalVariable(name: "s",{{.*}} line: 3, |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 8 | |
| 9 | ; |
| 10 | ; struct S { float f; }; |
| 11 | ; |
| 12 | ; float foo(struct S s) { |
| 13 | ; return s.f; |
| 14 | ; } |
| 15 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 16 | target triple = "x86_64-apple-macosx10.10.0" |
| 17 | |
| 18 | %struct.S = type { float } |
| 19 | |
| 20 | ; Function Attrs: nounwind ssp uwtable |
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 21 | define float @foo(float %s.coerce) #0 !dbg !4 { |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 22 | entry: |
| 23 | %s = alloca %struct.S, align 4 |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 24 | %coerce.dive = getelementptr %struct.S, %struct.S* %s, i32 0, i32 0 |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 25 | store float %s.coerce, float* %coerce.dive, align 1 |
| 26 | call void @llvm.dbg.declare(metadata %struct.S* %s, metadata !16, metadata !17), !dbg !18 |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 27 | %f = getelementptr inbounds %struct.S, %struct.S* %s, i32 0, i32 0, !dbg !19 |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 28 | %0 = load float, float* %f, align 4, !dbg !19 |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 29 | ret float %0, !dbg !19 |
| 30 | } |
| 31 | |
| 32 | ; Function Attrs: nounwind readnone |
| 33 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 34 | |
| 35 | attributes #0 = { nounwind ssp uwtable } |
| 36 | attributes #1 = { nounwind readnone } |
| 37 | |
| 38 | !llvm.dbg.cu = !{!0} |
| 39 | !llvm.module.flags = !{!12, !13, !14} |
| 40 | !llvm.ident = !{!15} |
| 41 | |
| Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 42 | !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 43 | !1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm/_build.ninja.debug") |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 44 | !2 = !{} |
| Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 45 | !4 = distinct !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 46 | !5 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm/_build.ninja.debug") |
| 47 | !6 = !DISubroutineType(types: !7) |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 48 | !7 = !{!8, !9} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 49 | !8 = !DIBasicType(tag: DW_TAG_base_type, name: "float", size: 32, align: 32, encoding: DW_ATE_float) |
| 50 | !9 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", line: 1, size: 32, align: 32, file: !1, elements: !10) |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 51 | !10 = !{!11} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 52 | !11 = !DIDerivedType(tag: DW_TAG_member, name: "f", line: 1, size: 32, align: 32, file: !1, scope: !9, baseType: !8) |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 53 | !12 = !{i32 2, !"Dwarf Version", i32 2} |
| Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 54 | !13 = !{i32 2, !"Debug Info Version", i32 3} |
| Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 55 | !14 = !{i32 1, !"PIC Level", i32 2} |
| 56 | !15 = !{!"clang version 3.6.0 "} |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 57 | !16 = !DILocalVariable(name: "s", line: 3, arg: 1, scope: !4, file: !5, type: !9) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 58 | !17 = !DIExpression() |
| 59 | !18 = !DILocation(line: 3, column: 20, scope: !4) |
| 60 | !19 = !DILocation(line: 4, column: 2, scope: !4) |