1 ; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s 2 3 ; Test llvm.dbg.value for dynamic allocas moved onto the unsafe stack. 4 ; In the dynamic alloca case, the dbg.value does not change with the exception 5 ; of the alloca pointer in the first argument being replaced with the new stack 6 ; top address. 7 8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 9 target triple = "x86_64-unknown-linux-gnu" 10 11 define void @f(i32 %n) safestack !dbg !6 { 12 entry: 13 tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !11, metadata !14), !dbg !15 14 %0 = zext i32 %n to i64, !dbg !16 15 16 ; CHECK: store i8* %[[VLA:.*]], i8** @__safestack_unsafe_stack_ptr 17 ; CHECK: tail call void @llvm.dbg.value(metadata i8* %[[VLA]], i64 0, metadata ![[TYPE:.*]], metadata ![[EXPR:.*]]) 18 ; CHECK: call void @capture({{.*}} %[[VLA]]) 19 20 %vla = alloca i8, i64 %0, align 16, !dbg !16 21 tail call void @llvm.dbg.value(metadata i8* %vla, i64 0, metadata !12, metadata !17), !dbg !18 22 call void @capture(i8* nonnull %vla), !dbg !19 23 ret void, !dbg !20 24 } 25 26 declare void @capture(i8*) 27 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) 28 29 !llvm.dbg.cu = !{!0} 30 !llvm.module.flags = !{!3, !4} 31 !llvm.ident = !{!5} 32 33 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272832) (llvm/trunk 272831)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 34 !1 = !DIFile(filename: "../llvm/1.cc", directory: "/code/build-llvm") 35 !2 = !{} 36 !3 = !{i32 2, !"Dwarf Version", i32 4} 37 !4 = !{i32 2, !"Debug Info Version", i32 3} 38 !5 = !{!"clang version 3.9.0 (trunk 272832) (llvm/trunk 272831)"} 39 !6 = distinct !DISubprogram(name: "f", linkageName: "_Z1fi", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !10) 40 !7 = !DISubroutineType(types: !8) 41 !8 = !{null, !9} 42 !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 43 !10 = !{!11, !12} 44 !11 = !DILocalVariable(name: "n", arg: 1, scope: !6, file: !1, line: 2, type: !9) 45 46 ; CHECK-DAG: ![[TYPE]] = !DILocalVariable(name: "x", 47 !12 = !DILocalVariable(name: "x", scope: !6, file: !1, line: 3, type: !13) 48 !13 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 49 !14 = !DIExpression() 50 !15 = !DILocation(line: 2, column: 12, scope: !6) 51 !16 = !DILocation(line: 3, column: 3, scope: !6) 52 53 ; CHECK-DAG: ![[EXPR]] = !DIExpression(DW_OP_deref) 54 !17 = !DIExpression(DW_OP_deref) 55 !18 = !DILocation(line: 3, column: 8, scope: !6) 56 !19 = !DILocation(line: 4, column: 3, scope: !6) 57 !20 = !DILocation(line: 5, column: 1, scope: !6) 58