Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 1 | ; Test dwarf codegen for DILocalVariable of a byval function argument that |
| 2 | ; points to neither an argument nor an alloca. This kind of IR is generated by |
| 3 | ; SafeStack for unsafe byval arguments. |
Matt Arsenault | 9cac4e6 | 2019-06-19 00:25:39 +0000 | [diff] [blame] | 4 | ; RUN: llc -mtriple=x86_64-unknown-unknown -stop-after finalize-isel %s -o - | FileCheck %s |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 5 | |
| 6 | ; This was built by compiling the following source with SafeStack and |
| 7 | ; simplifying the result a little. |
| 8 | ; struct S { |
| 9 | ; int a[100]; |
| 10 | ; }; |
| 11 | ; |
| 12 | ; int f(S zzz, unsigned long len) { |
| 13 | ; return zzz.a[len]; |
| 14 | ; } |
| 15 | |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 16 | ; CHECK: ![[ZZZ:.*]] = !DILocalVariable(name: "zzz", |
Jeremy Morse | 6531a78 | 2020-02-05 17:27:44 +0000 | [diff] [blame] | 17 | ; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 18 | |
| 19 | %struct.S = type { [100 x i32] } |
| 20 | |
| 21 | @__safestack_unsafe_stack_ptr = external thread_local(initialexec) global i8* |
| 22 | |
| 23 | ; Function Attrs: norecurse nounwind readonly safestack uwtable |
| 24 | define i32 @_Z1f1Sm(%struct.S* byval nocapture readonly align 8 %zzz, i64 %len) #0 !dbg !12 { |
| 25 | entry: |
| 26 | %unsafe_stack_ptr = load i8*, i8** @__safestack_unsafe_stack_ptr, !dbg !22 |
| 27 | %unsafe_stack_static_top = getelementptr i8, i8* %unsafe_stack_ptr, i32 -400, !dbg !22 |
| 28 | store i8* %unsafe_stack_static_top, i8** @__safestack_unsafe_stack_ptr, !dbg !22 |
| 29 | ; !17 describes "zzz" |
| 30 | call void @llvm.dbg.declare(metadata i8* %unsafe_stack_ptr, metadata !17, metadata !23), !dbg !22 |
| 31 | %0 = getelementptr i8, i8* %unsafe_stack_ptr, i32 -400, !dbg !22 |
| 32 | %zzz.unsafe-byval = bitcast i8* %0 to %struct.S*, !dbg !22 |
| 33 | %1 = bitcast %struct.S* %zzz to i8*, !dbg !24 |
Daniel Neilson | 1e68724 | 2018-01-19 17:13:12 +0000 | [diff] [blame] | 34 | call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %0, i8* align 8 %1, i64 400, i1 false), !dbg !24 |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 35 | tail call void @llvm.dbg.value(metadata i64 %len, metadata !18, metadata !25), !dbg !24 |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 36 | %arrayidx = getelementptr inbounds %struct.S, %struct.S* %zzz.unsafe-byval, i64 0, i32 0, i64 %len, !dbg !26 |
| 37 | %2 = load i32, i32* %arrayidx, align 4, !dbg !26, !tbaa !27 |
| 38 | store i8* %unsafe_stack_ptr, i8** @__safestack_unsafe_stack_ptr, !dbg !31 |
| 39 | ret i32 %2, !dbg !31 |
| 40 | } |
| 41 | |
| 42 | ; Function Attrs: nounwind readnone |
| 43 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 44 | |
| 45 | ; Function Attrs: nounwind readnone |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 46 | declare void @llvm.dbg.value(metadata, metadata, metadata) #1 |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 47 | |
| 48 | ; Function Attrs: argmemonly nounwind |
Daniel Neilson | 1e68724 | 2018-01-19 17:13:12 +0000 | [diff] [blame] | 49 | declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) #2 |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 50 | |
Fangrui Song | a36ddf0 | 2019-12-24 16:11:33 -0800 | [diff] [blame] | 51 | attributes #0 = { norecurse nounwind readonly safestack uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 52 | attributes #1 = { nounwind readnone } |
| 53 | attributes #2 = { argmemonly nounwind } |
| 54 | |
| 55 | !llvm.dbg.cu = !{!0} |
| 56 | !llvm.module.flags = !{!19, !20} |
| 57 | !llvm.ident = !{!21} |
| 58 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 59 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 254107) (llvm/trunk 254109)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 60 | !1 = !DIFile(filename: "../llvm/1.cc", directory: "/tmp/build") |
| 61 | !2 = !{} |
| 62 | !3 = !{!4} |
| 63 | !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 4, size: 3200, align: 32, elements: !5, identifier: "_ZTS1S") |
| 64 | !5 = !{!6} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 65 | !6 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !4, file: !1, line: 5, baseType: !7, size: 3200, align: 32) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 66 | !7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 3200, align: 32, elements: !9) |
| 67 | !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 68 | !9 = !{!10} |
| 69 | !10 = !DISubrange(count: 100) |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 70 | !12 = distinct !DISubprogram(name: "f", linkageName: "_Z1f1Sm", scope: !1, file: !1, line: 8, type: !13, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 71 | !13 = !DISubroutineType(types: !14) |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 72 | !14 = !{!8, !4, !15} |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 73 | !15 = !DIBasicType(name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) |
| 74 | !16 = !{!17, !18} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 75 | !17 = !DILocalVariable(name: "zzz", arg: 1, scope: !12, file: !1, line: 8, type: !4) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 76 | !18 = !DILocalVariable(name: "len", arg: 2, scope: !12, file: !1, line: 8, type: !15) |
| 77 | !19 = !{i32 2, !"Dwarf Version", i32 4} |
| 78 | !20 = !{i32 2, !"Debug Info Version", i32 3} |
| 79 | !21 = !{!"clang version 3.8.0 (trunk 254107) (llvm/trunk 254109)"} |
| 80 | !22 = !DILocation(line: 8, column: 9, scope: !12) |
Jeremy Morse | 6531a78 | 2020-02-05 17:27:44 +0000 | [diff] [blame] | 81 | !23 = !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus) |
Evgeniy Stepanov | fd07995 | 2015-12-01 00:34:30 +0000 | [diff] [blame] | 82 | !24 = !DILocation(line: 8, column: 28, scope: !12) |
| 83 | !25 = !DIExpression() |
| 84 | !26 = !DILocation(line: 9, column: 10, scope: !12) |
| 85 | !27 = !{!28, !28, i64 0} |
| 86 | !28 = !{!"int", !29, i64 0} |
| 87 | !29 = !{!"omnipotent char", !30, i64 0} |
| 88 | !30 = !{!"Simple C/C++ TBAA"} |
| 89 | !31 = !DILocation(line: 9, column: 3, scope: !12) |