1; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s 2; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - --try-experimental-debuginfo-iterators | FileCheck %s 3; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s 4; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - --try-experimental-debuginfo-iterators | FileCheck %s 5 6; Test debug location for the local variables moved onto the unsafe stack. 7 8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 9target triple = "x86_64-unknown-linux-gnu" 10 11%struct.S = type { [100 x i8] } 12 13; Function Attrs: safestack uwtable 14define void @f(ptr byval(%struct.S) align 8 %zzz) #0 !dbg !12 { 15; CHECK: define void @f 16 17entry: 18; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr 19 20 %xxx = alloca %struct.S, align 1 21 call void @llvm.dbg.declare(metadata ptr %zzz, metadata !18, metadata !19), !dbg !20 22 call void @llvm.dbg.declare(metadata ptr %xxx, metadata !21, metadata !19), !dbg !22 23 24; dbg.declare for %zzz and %xxx are gone; replaced with dbg.declare based off the unsafe stack pointer 25; CHECK-NOT: #dbg_declare 26; CHECK: #dbg_declare(ptr %[[USP]], ![[VAR_ARG:.*]], !DIExpression(DW_OP_constu, 104, DW_OP_minus), 27; CHECK-NOT: #dbg_declare 28; CHECK: #dbg_declare(ptr %[[USP]], ![[VAR_LOCAL:.*]], !DIExpression(DW_OP_constu, 208, DW_OP_minus), 29; CHECK-NOT: #dbg_declare 30 31 call void @Capture(ptr %zzz), !dbg !23 32 call void @Capture(ptr %xxx), !dbg !24 33 34; dbg.declare appears before the first use 35; CHECK: call void @Capture 36; CHECK: call void @Capture 37 38 ret void, !dbg !25 39} 40 41; CHECK-DAG: ![[VAR_ARG]] = !DILocalVariable(name: "zzz" 42; 100 aligned up to 8 43 44; CHECK-DAG: ![[VAR_LOCAL]] = !DILocalVariable(name: "xxx" 45 46; Function Attrs: nounwind readnone 47declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 48 49declare void @Capture(ptr) #2 50 51attributes #0 = { safestack uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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" } 52attributes #1 = { nounwind readnone } 53attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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" } 54 55!llvm.dbg.cu = !{!0} 56!llvm.module.flags = !{!15, !16} 57!llvm.ident = !{!17} 58 59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 254019) (llvm/trunk 254036)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3) 60!1 = !DIFile(filename: "../llvm/2.cc", directory: "/code/build-llvm") 61!2 = !{} 62!3 = !{!4} 63!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 4, size: 800, align: 8, elements: !5, identifier: "_ZTS1S") 64!5 = !{!6} 65!6 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !4, file: !1, line: 5, baseType: !7, size: 800, align: 8) 66!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 800, align: 8, elements: !9) 67!8 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 68!9 = !{!10} 69!10 = !DISubrange(count: 100) 70!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1f1S", scope: !1, file: !1, line: 10, type: !13, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 71!13 = !DISubroutineType(types: !14) 72!14 = !{null, !4} 73!15 = !{i32 2, !"Dwarf Version", i32 4} 74!16 = !{i32 2, !"Debug Info Version", i32 3} 75!17 = !{!"clang version 3.8.0 (trunk 254019) (llvm/trunk 254036)"} 76!18 = !DILocalVariable(name: "zzz", arg: 1, scope: !12, file: !1, line: 10, type: !4) 77!19 = !DIExpression() 78!20 = !DILocation(line: 10, column: 10, scope: !12) 79!21 = !DILocalVariable(name: "xxx", scope: !12, file: !1, line: 11, type: !4) 80!22 = !DILocation(line: 11, column: 5, scope: !12) 81!23 = !DILocation(line: 12, column: 3, scope: !12) 82!24 = !DILocation(line: 13, column: 3, scope: !12) 83!25 = !DILocation(line: 14, column: 1, scope: !12) 84