brintos

brintos / llvm-project-archived public Read only

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