1; RUN: opt -safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s 2; RUN: opt -passes=safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s 3; RUN: opt --try-experimental-debuginfo-iterators -passes=safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s 4 5target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 6target triple = "armv7-pc-linux-android" 7 8; Original C used to generate debug info: 9; char*** addr; 10; char** __safestack_pointer_address() { 11; return *addr; 12; } 13; void Capture(char*x); 14; void f() { char c[16]; Capture(c); } 15 16; CHECK: !36 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !37) 17; CHECK: !37 = distinct !DILocation(line: 6, scope: !27) 18 19@addr = common local_unnamed_addr global ptr null, align 4, !dbg !0 20 21; Function Attrs: norecurse nounwind readonly safestack 22define ptr @__safestack_pointer_address() local_unnamed_addr #0 !dbg !17 { 23entry: 24 %0 = load ptr, ptr @addr, align 4, !dbg !20, !tbaa !21 25 %1 = load ptr, ptr %0, align 4, !dbg !25, !tbaa !21 26 ret ptr %1, !dbg !26 27} 28 29; Function Attrs: nounwind safestack 30define void @f() local_unnamed_addr #1 !dbg !27 { 31entry: 32 %c = alloca [16 x i8], align 1 33 call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %c) #5, !dbg !35 34 call void @llvm.dbg.declare(metadata ptr %c, metadata !31, metadata !DIExpression()), !dbg !36 35 call void @Capture(ptr nonnull %c) #5, !dbg !37 36 call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %c) #5, !dbg !38 37 ret void, !dbg !38 38} 39 40; Function Attrs: argmemonly nounwind 41declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #2 42 43; Function Attrs: nounwind readnone speculatable 44declare void @llvm.dbg.declare(metadata, metadata, metadata) #3 45 46declare void @Capture(ptr) local_unnamed_addr #4 47 48; Function Attrs: argmemonly nounwind 49declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #2 50 51attributes #0 = { norecurse nounwind readonly safestack "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="generic" "target-features"="+armv7-a,+dsp,+neon,+vfp3,-thumb-mode" "unsafe-fp-math"="false" "use-soft-float"="false" } 52attributes #1 = { nounwind safestack "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="generic" "target-features"="+armv7-a,+dsp,+neon,+vfp3,-thumb-mode" "unsafe-fp-math"="false" "use-soft-float"="false" } 53attributes #2 = { argmemonly nounwind } 54attributes #3 = { nounwind readnone speculatable } 55attributes #4 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+armv7-a,+dsp,+neon,+vfp3,-thumb-mode" "unsafe-fp-math"="false" "use-soft-float"="false" } 56attributes #5 = { nounwind } 57 58!llvm.dbg.cu = !{!2} 59!llvm.module.flags = !{!11, !12, !13, !14, !15} 60!llvm.ident = !{!16} 61 62!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 63!1 = distinct !DIGlobalVariable(name: "addr", scope: !2, file: !6, line: 1, type: !7, isLocal: false, isDefinition: true) 64!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 65!3 = !DIFile(filename: "-", directory: "/") 66!4 = !{} 67!5 = !{!0} 68!6 = !DIFile(filename: "<stdin>", directory: "/") 69!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32) 70!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32) 71!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32) 72!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char) 73!11 = !{i32 2, !"Dwarf Version", i32 4} 74!12 = !{i32 2, !"Debug Info Version", i32 3} 75!13 = !{i32 1, !"wchar_size", i32 4} 76!14 = !{i32 1, !"min_enum_size", i32 4} 77!15 = !{i32 7, !"PIC Level", i32 1} 78!16 = !{!"clang"} 79!17 = distinct !DISubprogram(name: "__safestack_pointer_address", scope: !6, file: !6, line: 2, type: !18, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !2, retainedNodes: !4) 80!18 = !DISubroutineType(types: !19) 81!19 = !{!8} 82!20 = !DILocation(line: 3, column: 11, scope: !17) 83!21 = !{!22, !22, i64 0} 84!22 = !{!"any pointer", !23, i64 0} 85!23 = !{!"omnipotent char", !24, i64 0} 86!24 = !{!"Simple C/C++ TBAA"} 87!25 = !DILocation(line: 3, column: 10, scope: !17) 88!26 = !DILocation(line: 3, column: 3, scope: !17) 89!27 = distinct !DISubprogram(name: "f", scope: !6, file: !6, line: 6, type: !28, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !2, retainedNodes: !30) 90!28 = !DISubroutineType(types: !29) 91!29 = !{null} 92!30 = !{!31} 93!31 = !DILocalVariable(name: "c", scope: !27, file: !6, line: 6, type: !32) 94!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 128, elements: !33) 95!33 = !{!34} 96!34 = !DISubrange(count: 16) 97!35 = !DILocation(line: 6, column: 12, scope: !27) 98!36 = !DILocation(line: 6, column: 17, scope: !27) 99!37 = !DILocation(line: 6, column: 24, scope: !27) 100!38 = !DILocation(line: 6, column: 36, scope: !27) 101