Evgeniy Stepanov | f608111 | 2015-09-30 19:55:43 +0000 | [diff] [blame^] | 1 | ; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s |
| 2 | |
| 3 | ; Test debug location for the local variables moved onto the unsafe stack. |
| 4 | ; CHECK: define void @f |
| 5 | ; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr |
| 6 | |
| 7 | ; dbg.declare for %buf is gone; replaced with dbg.declare based off the unsafe stack pointer |
| 8 | ; CHECK-NOT: @llvm.dbg.declare.*%buf |
| 9 | ; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR:.*]], metadata ![[EXPR:.*]]) |
| 10 | |
| 11 | ; dbg.declare appears before the first use of %buf |
| 12 | ; CHECK: getelementptr{{.*}}%buf |
| 13 | ; CHECK: call{{.*}}@Capture |
| 14 | ; CHECK: ret void |
| 15 | |
| 16 | ; dbg.declare describes "buf"... |
| 17 | ; CHECK: ![[VAR]] = !DILocalVariable(name: "buf" |
| 18 | |
| 19 | ; ... as an offset from the unsafe stack pointer |
| 20 | ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref, DW_OP_minus, 400) |
| 21 | |
| 22 | |
| 23 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 24 | target triple = "x86_64-unknown-linux-gnu" |
| 25 | |
| 26 | ; Function Attrs: safestack uwtable |
| 27 | define void @f() #0 { |
| 28 | entry: |
| 29 | %buf = alloca [100 x i32], align 16 |
| 30 | %0 = bitcast [100 x i32]* %buf to i8*, !dbg !16 |
| 31 | call void @llvm.lifetime.start(i64 400, i8* %0) #4, !dbg !16 |
| 32 | tail call void @llvm.dbg.declare(metadata [100 x i32]* %buf, metadata !8, metadata !17), !dbg !18 |
| 33 | |
| 34 | |
| 35 | %arraydecay = getelementptr inbounds [100 x i32], [100 x i32]* %buf, i64 0, i64 0, !dbg !19 |
| 36 | call void @Capture(i32* %arraydecay), !dbg !20 |
| 37 | call void @llvm.lifetime.end(i64 400, i8* %0) #4, !dbg !21 |
| 38 | ret void, !dbg !21 |
| 39 | } |
| 40 | |
| 41 | ; Function Attrs: nounwind argmemonly |
| 42 | declare void @llvm.lifetime.start(i64, i8* nocapture) #1 |
| 43 | |
| 44 | ; Function Attrs: nounwind readnone |
| 45 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #2 |
| 46 | |
| 47 | declare void @Capture(i32*) #3 |
| 48 | |
| 49 | ; Function Attrs: nounwind argmemonly |
| 50 | declare void @llvm.lifetime.end(i64, i8* nocapture) #1 |
| 51 | |
| 52 | attributes #0 = { safestack uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 53 | attributes #1 = { nounwind argmemonly } |
| 54 | attributes #2 = { nounwind readnone } |
| 55 | attributes #3 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 56 | attributes #4 = { nounwind } |
| 57 | |
| 58 | !llvm.dbg.cu = !{!0} |
| 59 | !llvm.module.flags = !{!13, !14} |
| 60 | !llvm.ident = !{!15} |
| 61 | |
| 62 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 248518) (llvm/trunk 248512)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) |
| 63 | !1 = !DIFile(filename: "1.cc", directory: "/tmp") |
| 64 | !2 = !{} |
| 65 | !3 = !{!4} |
| 66 | !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, function: void ()* @f, variables: !7) |
| 67 | !5 = !DISubroutineType(types: !6) |
| 68 | !6 = !{null} |
| 69 | !7 = !{!8} |
| 70 | !8 = !DILocalVariable(name: "buf", scope: !4, file: !1, line: 5, type: !9) |
| 71 | !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 3200, align: 32, elements: !11) |
| 72 | !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 73 | !11 = !{!12} |
| 74 | !12 = !DISubrange(count: 100) |
| 75 | !13 = !{i32 2, !"Dwarf Version", i32 4} |
| 76 | !14 = !{i32 2, !"Debug Info Version", i32 3} |
| 77 | !15 = !{!"clang version 3.8.0 (trunk 248518) (llvm/trunk 248512)"} |
| 78 | !16 = !DILocation(line: 5, column: 3, scope: !4) |
| 79 | !17 = !DIExpression() |
| 80 | !18 = !DILocation(line: 5, column: 7, scope: !4) |
| 81 | !19 = !DILocation(line: 6, column: 11, scope: !4) |
| 82 | !20 = !DILocation(line: 6, column: 3, scope: !4) |
| 83 | !21 = !DILocation(line: 7, column: 1, scope: !4) |