1cee313d2SEric Christopher; RUN: opt -safe-stack -safestack-use-pointer-address < %s -S | FileCheck %s 2cee313d2SEric Christophertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 3cee313d2SEric Christophertarget triple = "armv7-pc-linux-android" 4cee313d2SEric Christopher 5cee313d2SEric Christopher; Original C used to generate debug info: 6cee313d2SEric Christopher; char*** addr; 7cee313d2SEric Christopher; char** __safestack_pointer_address() { 8cee313d2SEric Christopher; return *addr; 9cee313d2SEric Christopher; } 10cee313d2SEric Christopher; void Capture(char*x); 11cee313d2SEric Christopher; void f() { char c[16]; Capture(c); } 12cee313d2SEric Christopher 13*61e36e87SPaul Kirth; CHECK: !36 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !37) 14*61e36e87SPaul Kirth; CHECK: !37 = distinct !DILocation(line: 6, scope: !27) 15cee313d2SEric Christopher 16cee313d2SEric Christopher@addr = common local_unnamed_addr global i8*** null, align 4, !dbg !0 17cee313d2SEric Christopher 18cee313d2SEric Christopher; Function Attrs: norecurse nounwind readonly safestack 19cee313d2SEric Christopherdefine i8** @__safestack_pointer_address() local_unnamed_addr #0 !dbg !17 { 20cee313d2SEric Christopherentry: 21cee313d2SEric Christopher %0 = load i8***, i8**** @addr, align 4, !dbg !20, !tbaa !21 22cee313d2SEric Christopher %1 = load i8**, i8*** %0, align 4, !dbg !25, !tbaa !21 23cee313d2SEric Christopher ret i8** %1, !dbg !26 24cee313d2SEric Christopher} 25cee313d2SEric Christopher 26cee313d2SEric Christopher; Function Attrs: nounwind safestack 27cee313d2SEric Christopherdefine void @f() local_unnamed_addr #1 !dbg !27 { 28cee313d2SEric Christopherentry: 29cee313d2SEric Christopher %c = alloca [16 x i8], align 1 30cee313d2SEric Christopher %0 = getelementptr inbounds [16 x i8], [16 x i8]* %c, i32 0, i32 0, !dbg !35 31cee313d2SEric Christopher call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0) #5, !dbg !35 32cee313d2SEric Christopher call void @llvm.dbg.declare(metadata [16 x i8]* %c, metadata !31, metadata !DIExpression()), !dbg !36 33cee313d2SEric Christopher call void @Capture(i8* nonnull %0) #5, !dbg !37 34cee313d2SEric Christopher call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0) #5, !dbg !38 35cee313d2SEric Christopher ret void, !dbg !38 36cee313d2SEric Christopher} 37cee313d2SEric Christopher 38cee313d2SEric Christopher; Function Attrs: argmemonly nounwind 39cee313d2SEric Christopherdeclare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2 40cee313d2SEric Christopher 41cee313d2SEric Christopher; Function Attrs: nounwind readnone speculatable 42cee313d2SEric Christopherdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #3 43cee313d2SEric Christopher 44cee313d2SEric Christopherdeclare void @Capture(i8*) local_unnamed_addr #4 45cee313d2SEric Christopher 46cee313d2SEric Christopher; Function Attrs: argmemonly nounwind 47cee313d2SEric Christopherdeclare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2 48cee313d2SEric Christopher 494ab3041aSserge-sans-pailleattributes #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" } 504ab3041aSserge-sans-pailleattributes #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" } 51cee313d2SEric Christopherattributes #2 = { argmemonly nounwind } 52cee313d2SEric Christopherattributes #3 = { nounwind readnone speculatable } 534ab3041aSserge-sans-pailleattributes #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" } 54cee313d2SEric Christopherattributes #5 = { nounwind } 55cee313d2SEric Christopher 56cee313d2SEric Christopher!llvm.dbg.cu = !{!2} 57cee313d2SEric Christopher!llvm.module.flags = !{!11, !12, !13, !14, !15} 58cee313d2SEric Christopher!llvm.ident = !{!16} 59cee313d2SEric Christopher 60cee313d2SEric Christopher!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 61cee313d2SEric Christopher!1 = distinct !DIGlobalVariable(name: "addr", scope: !2, file: !6, line: 1, type: !7, isLocal: false, isDefinition: true) 62cee313d2SEric Christopher!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 63cee313d2SEric Christopher!3 = !DIFile(filename: "-", directory: "/") 64cee313d2SEric Christopher!4 = !{} 65cee313d2SEric Christopher!5 = !{!0} 66cee313d2SEric Christopher!6 = !DIFile(filename: "<stdin>", directory: "/") 67cee313d2SEric Christopher!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32) 68cee313d2SEric Christopher!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32) 69cee313d2SEric Christopher!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32) 70cee313d2SEric Christopher!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char) 71cee313d2SEric Christopher!11 = !{i32 2, !"Dwarf Version", i32 4} 72cee313d2SEric Christopher!12 = !{i32 2, !"Debug Info Version", i32 3} 73cee313d2SEric Christopher!13 = !{i32 1, !"wchar_size", i32 4} 74cee313d2SEric Christopher!14 = !{i32 1, !"min_enum_size", i32 4} 75cee313d2SEric Christopher!15 = !{i32 7, !"PIC Level", i32 1} 76cee313d2SEric Christopher!16 = !{!"clang"} 77cee313d2SEric Christopher!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) 78cee313d2SEric Christopher!18 = !DISubroutineType(types: !19) 79cee313d2SEric Christopher!19 = !{!8} 80cee313d2SEric Christopher!20 = !DILocation(line: 3, column: 11, scope: !17) 81cee313d2SEric Christopher!21 = !{!22, !22, i64 0} 82cee313d2SEric Christopher!22 = !{!"any pointer", !23, i64 0} 83cee313d2SEric Christopher!23 = !{!"omnipotent char", !24, i64 0} 84cee313d2SEric Christopher!24 = !{!"Simple C/C++ TBAA"} 85cee313d2SEric Christopher!25 = !DILocation(line: 3, column: 10, scope: !17) 86cee313d2SEric Christopher!26 = !DILocation(line: 3, column: 3, scope: !17) 87cee313d2SEric Christopher!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) 88cee313d2SEric Christopher!28 = !DISubroutineType(types: !29) 89cee313d2SEric Christopher!29 = !{null} 90cee313d2SEric Christopher!30 = !{!31} 91cee313d2SEric Christopher!31 = !DILocalVariable(name: "c", scope: !27, file: !6, line: 6, type: !32) 92cee313d2SEric Christopher!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 128, elements: !33) 93cee313d2SEric Christopher!33 = !{!34} 94cee313d2SEric Christopher!34 = !DISubrange(count: 16) 95cee313d2SEric Christopher!35 = !DILocation(line: 6, column: 12, scope: !27) 96cee313d2SEric Christopher!36 = !DILocation(line: 6, column: 17, scope: !27) 97cee313d2SEric Christopher!37 = !DILocation(line: 6, column: 24, scope: !27) 98cee313d2SEric Christopher!38 = !DILocation(line: 6, column: 36, scope: !27) 99