Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 1 | ; Checks that llvm.dbg.declare -> llvm.dbg.value conversion utility |
| 2 | ; (here exposed through the SROA) pass, properly inserts bit_piece expressions |
| 3 | ; if it only describes part of the variable. |
| 4 | ; RUN: opt -S -sroa %s | FileCheck %s |
| 5 | |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 6 | ; Built from: |
| 7 | ; struct foo { bool b; long i; }; |
| 8 | ; void f(bool b, bool expr, foo g) { |
| 9 | ; } |
| 10 | ; And modifying the frag dbg.declare to use a fragmented DIExpression (with offset: 0, size: 4) |
| 11 | ; to test the dbg.declare+fragment case here. |
Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 12 | |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 13 | ; Expect two fragments: |
| 14 | ; * first starting at bit 0, 8 bits (for the bool) |
| 15 | ; * second starting at bit 32, 32 bits (for the long) |
| 16 | ; (this happens to create/demonstrate a gap from bits [7, 32)) |
| 17 | |
| 18 | ; But also check that a complex expression is not used for a lone bool |
| 19 | ; parameter. It can reference the register it's in directly without masking off |
| 20 | ; high bits or anything |
| 21 | |
Reid Kleckner | 6d35334 | 2017-08-23 20:31:27 +0000 | [diff] [blame^] | 22 | ; CHECK: call void @llvm.dbg.value(metadata i8 %g.coerce0, metadata ![[VAR_STRUCT:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8)) |
| 23 | ; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 64)) |
| 24 | ; CHECK: call void @llvm.dbg.value(metadata i1 %b, metadata ![[VAR_BOOL:[0-9]+]], metadata !DIExpression()) |
| 25 | ; CHECK: call void @llvm.dbg.value(metadata i1 %frag, metadata ![[VAR_FRAG:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 1)) |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 26 | |
| 27 | %struct.foo = type { i8, i64 } |
| 28 | |
| 29 | ; Function Attrs: noinline nounwind uwtable |
| 30 | define void @_Z1fbb3foo(i1 zeroext %b, i1 zeroext %frag, i8 %g.coerce0, i64 %g.coerce1) #0 !dbg !6 { |
Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 31 | entry: |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 32 | %g = alloca %struct.foo, align 8 |
| 33 | %b.addr = alloca i8, align 1 |
| 34 | %frag.addr = alloca i8, align 1 |
| 35 | %0 = bitcast %struct.foo* %g to { i8, i64 }* |
| 36 | %1 = getelementptr inbounds { i8, i64 }, { i8, i64 }* %0, i32 0, i32 0 |
| 37 | store i8 %g.coerce0, i8* %1, align 8 |
| 38 | %2 = getelementptr inbounds { i8, i64 }, { i8, i64 }* %0, i32 0, i32 1 |
| 39 | store i64 %g.coerce1, i64* %2, align 8 |
| 40 | %frombool = zext i1 %b to i8 |
| 41 | store i8 %frombool, i8* %b.addr, align 1 |
| 42 | call void @llvm.dbg.declare(metadata i8* %b.addr, metadata !15, metadata !16), !dbg !17 |
| 43 | %frombool1 = zext i1 %frag to i8 |
| 44 | store i8 %frombool1, i8* %frag.addr, align 1 |
| 45 | call void @llvm.dbg.declare(metadata i8* %frag.addr, metadata !18, metadata !23), !dbg !19 |
| 46 | call void @llvm.dbg.declare(metadata %struct.foo* %g, metadata !20, metadata !16), !dbg !21 |
| 47 | ret void, !dbg !22 |
Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 48 | } |
| 49 | |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 50 | ; Function Attrs: nounwind readnone speculatable |
| 51 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 52 | |
| 53 | attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 54 | attributes #1 = { nounwind readnone speculatable } |
Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 55 | |
| 56 | !llvm.dbg.cu = !{!0} |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 57 | !llvm.module.flags = !{!3, !4} |
| 58 | !llvm.ident = !{!5} |
Keno Fischer | 9aae445 | 2016-01-12 22:46:09 +0000 | [diff] [blame] | 59 | |
David Blaikie | 441cfee | 2017-05-15 21:34:01 +0000 | [diff] [blame] | 60 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 303077) (llvm/trunk 303098)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) |
| 61 | !1 = !DIFile(filename: "foo.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") |
| 62 | !2 = !{} |
| 63 | !3 = !{i32 2, !"Dwarf Version", i32 4} |
| 64 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
| 65 | !5 = !{!"clang version 5.0.0 (trunk 303077) (llvm/trunk 303098)"} |
| 66 | !6 = distinct !DISubprogram(name: "f", linkageName: "_Z1fbb3foo", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) |
| 67 | !7 = !DISubroutineType(types: !8) |
| 68 | !8 = !{null, !9, !9, !10} |
| 69 | !9 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) |
| 70 | !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 1, size: 128, elements: !11, identifier: "_ZTS3foo") |
| 71 | !11 = !{!12, !13} |
| 72 | !12 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !10, file: !1, line: 1, baseType: !9, size: 8) |
| 73 | !13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !10, file: !1, line: 1, baseType: !14, size: 64, offset: 64) |
| 74 | !14 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) |
| 75 | !15 = !DILocalVariable(name: "b", arg: 1, scope: !6, file: !1, line: 2, type: !9) |
| 76 | !16 = !DIExpression() |
| 77 | !17 = !DILocation(line: 2, column: 13, scope: !6) |
| 78 | !18 = !DILocalVariable(name: "frag", arg: 2, scope: !6, file: !1, line: 2, type: !9) |
| 79 | !19 = !DILocation(line: 2, column: 21, scope: !6) |
| 80 | !20 = !DILocalVariable(name: "g", arg: 3, scope: !6, file: !1, line: 2, type: !10) |
| 81 | !21 = !DILocation(line: 2, column: 31, scope: !6) |
| 82 | !22 = !DILocation(line: 3, column: 1, scope: !6) |
| 83 | !23 = !DIExpression(DW_OP_LLVM_fragment, 0, 4) |