brintos

brintos / llvm-project-archived public Read only

0
0
Text · 14.9 KiB · ea059e4 Raw
331 lines · plain
1; Test remark output for stack-frame-layout2 3; ensure basic output works4; RUN: llc -mtriple=arm-eabi -O1 -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s5 6; check additional slots are displayed when stack is not optimized7; RUN: llc -mtriple=arm-eabi -O0  -pass-remarks-analysis=stack-frame-layout < %s 2>&1 >/dev/null | FileCheck %s --check-prefix=NO_COLORING8 9; check more complex cases10; RUN: llc %s  -pass-remarks-analysis=stack-frame-layout -o /dev/null --mtriple=arm -mcpu=cortex-m1 2>&1 | FileCheck %s --check-prefix=BOTH --check-prefix=DEBUG11 12; check output without debug info13; RUN: opt %s -passes=strip -S | llc   -pass-remarks-analysis=stack-frame-layout -o /dev/null --mtriple=arm -mcpu=cortex-m1 2>&1 | FileCheck %s --check-prefix=BOTH --check-prefix=STRIPPED14 15target triple = "x86_64-unknown-linux-gnu"16 17@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 118declare i32 @printf(ptr, ...)19 20; CHECK: Function: stackSizeWarning21; CHECK: [SP-4]{{.*}}Spill{{.*}}4{{.*}}422; CHECK: [SP-96]{{.*}}16{{.*}}8023; CHECK:    buffer @ frame-diags.c:3024; NO_COLORING: [SP-176]{{.*}}16{{.*}}8025; CHECK:    buffer2 @ frame-diags.c:3326 27; BOTH: Function: stackSizeWarning28; BOTH: [SP-4]{{.*}}Spill{{.*}}4{{.*}}429; BOTH: [SP-8]{{.*}}Spill{{.*}}4{{.*}}430; BOTH: [SP-12]{{.*}}Spill{{.*}}4{{.*}}431; BOTH: [SP-16]{{.*}}Spill{{.*}}4{{.*}}432; BOTH: [SP-96]{{.*}}16{{.*}}8033; DEBUG: buffer @ frame-diags.c:3034; STRIPPED-NOT: buffer @ frame-diags.c:3035; BOTH: [SP-176]{{.*}}16{{.*}}8036; DEBUG: buffer2 @ frame-diags.c:3337; STRIPPED-NOT: buffer2 @ frame-diags.c:3338define void @stackSizeWarning() {39entry:40  %buffer = alloca [80 x i8], align 1641  %buffer2 = alloca [80 x i8], align 1642  call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !3943  call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !4044  ret void45}46 47; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn48declare void @llvm.dbg.declare(metadata, metadata, metadata) #049 50; BOTH: Function: cleanup_array51; BOTH:  [SP-8]{{.+}}8{{.+}}452; DEBUG: a @ dot.c:1353; STRIPPED-NOT: a @ dot.c:1354define void @cleanup_array(ptr %0) #3 {55  %2 = alloca ptr, align 856  store ptr %0, ptr %2, align 857  call void @llvm.dbg.declare(metadata ptr %2, metadata !41, metadata !DIExpression()), !dbg !4658  ret void59}60 61; BOTH: Function: cleanup_result62; BOTH:  [SP-8]{{.+}}8{{.+}}463; DEBUG: res @ dot.c:2164; STRIPPED-NOT: res @ dot.c:2165define void @cleanup_result(ptr %0) #3 {66  %2 = alloca ptr, align 867  store ptr %0, ptr %2, align 868  call void @llvm.dbg.declare(metadata ptr %2, metadata !47, metadata !DIExpression()), !dbg !5169  ret void70}71 72; BOTH: Function: do_work73; BOTH:  [SP-4]{{.+}}4{{.+}}474; BOTH:  [SP-8]{{.+}}8{{.+}}475; DEBUG: A @ dot.c:3276; STRIPPED-NOT: A @ dot.c:3277; BOTH:  [SP-16]{{.+}}8{{.+}}478; DEBUG: B @ dot.c:3279; STRIPPED-NOT: B @ dot.c:3280; BOTH:  [SP-24]{{.+}}8{{.+}}481; DEBUG: out @ dot.c:3282; STRIPPED-NOT: out @ dot.c:3283; BOTH:  [SP-28]{{.+}}4{{.+}}484; DEBUG: len @ dot.c:3785; STRIPPED-NOT: len @ dot.c:3786; BOTH:  [SP-32]{{.+}}8{{.+}}487; DEBUG: AB @ dot.c:3888; STRIPPED-NOT: AB @ dot.c:3889; BOTH:  [SP-36]{{.+}}4{{.+}}490; DEBUG: sum @ dot.c:5491; STRIPPED-NOT: sum @ dot.c:5492; BOTH:  [SP-40]{{.+}}4{{.+}}493; DEBUG: i @ dot.c:5594; STRIPPED-NOT: i @ dot.c:5595define i32 @do_work(ptr %0, ptr %1, ptr %2) #3 {96  %4 = alloca i32, align 497  %5 = alloca ptr, align 898  %6 = alloca ptr, align 899  %7 = alloca ptr, align 8100  %8 = alloca i32, align 4101  %9 = alloca ptr, align 8102  %10 = alloca i32, align 4103  %11 = alloca i32, align 4104  store ptr %0, ptr %5, align 8105  call void @llvm.dbg.declare(metadata ptr %5, metadata !52, metadata !DIExpression()), !dbg !56106  call void @llvm.dbg.declare(metadata ptr %6, metadata !57, metadata !DIExpression()), !dbg !58107  store ptr %2, ptr %7, align 8108  call void @llvm.dbg.declare(metadata ptr %7, metadata !59, metadata !DIExpression()), !dbg !60109  call void @llvm.dbg.declare(metadata ptr %8, metadata !61, metadata !DIExpression()), !dbg !63110  call void @llvm.dbg.declare(metadata ptr %9, metadata !64, metadata !DIExpression()), !dbg !65111  store ptr null, ptr %9, align 8112  store ptr null, ptr null, align 8113  store i32 0, ptr %9, align 8114  %12 = load i32, ptr %8, align 4115  store i32 %12, ptr null, align 8116  call void @llvm.dbg.declare(metadata ptr %10, metadata !66, metadata !DIExpression()), !dbg !67117  call void @llvm.dbg.declare(metadata ptr %11, metadata !68, metadata !DIExpression()), !dbg !70118  store i32 0, ptr %11, align 4119  br label %13120 12113:                                               ; preds = %16, %3122  %14 = load i32, ptr %11, align 4123  %15 = icmp slt i32 %14, 0124  br i1 %15, label %16, label %18125 12616:                                               ; preds = %13127  %17 = load i32, ptr %6, align 4128  store i32 %17, ptr null, align 4129  br label %13130 13118:                                               ; preds = %13132  store i32 0, ptr %4, align 4133  ret i32 0134}135 136; BOTH: Function: gen_array137; BOTH:  [SP-8]{{.+}}8{{.+}}4138; BOTH:  [SP-12]{{.+}}4{{.+}}4139; DEBUG: size @ dot.c:62140; STRIPPED-NOT: size @ dot.c:65141; BOTH:  [SP-16]{{.+}}8{{.+}}4142; DEBUG: res @ dot.c:65143; STRIPPED-NOT: res @ dot.c:65144; BOTH:  [SP-20]{{.+}}4{{.*}}4145; DEBUG: i @ dot.c:69146; STRIPPED-NOT: i @ dot.c:69147define ptr @gen_array(i32 %0) #3 {148  %2 = alloca ptr, align 8149  %3 = alloca i32, align 4150  %4 = alloca ptr, align 8151  %5 = alloca i32, align 4152  store i32 %0, ptr %3, align 4153  call void @llvm.dbg.declare(metadata ptr %3, metadata !71, metadata !DIExpression()), !dbg !75154  call void @llvm.dbg.declare(metadata ptr %4, metadata !76, metadata !DIExpression()), !dbg !77155  store ptr null, ptr %4, align 8156  call void @llvm.dbg.declare(metadata ptr %5, metadata !78, metadata !DIExpression()), !dbg !80157  store i32 0, ptr %5, align 4158  ret ptr null159}160 161 162; BOTH: Function: caller163; BOTH: [SP-4]{{.*}}Spill{{.*}}4{{.*}}4164; BOTH: [SP-8]{{.*}}Spill{{.*}}4{{.*}}4165; BOTH: [SP-12]{{.*}}Spill{{.*}}4{{.*}}4166; BOTH: [SP-16]{{.*}}Spill{{.*}}4{{.*}}4167; BOTH: [SP-20]{{.*}}4{{.*}}4168; BOTH: [SP-24]{{.*}}4{{.*}}4169; DEBUG: size @ dot.c:77170; STRIPPED-NOT: size @ dot.c:77171; BOTH: [SP-32]{{.*}}8{{.*}}4172; DEBUG: A @ dot.c:78173; STRIPPED-NOT: A @ dot.c:78174; BOTH: [SP-40]{{.*}}8{{.*}}4175; DEBUG: B @ dot.c:79176; STRIPPED-NOT: B @ dot.c:79177; BOTH: [SP-48]{{.*}}8{{.*}}4178; DEBUG: res @ dot.c:80179; STRIPPED-NOT: res @ dot.c:80180; BOTH: [SP-52]{{.*}}4{{.*}}4181; DEBUG: ret @ dot.c:81182; STRIPPED-NOT: ret @ dot.c:81183; BOTH: [SP-56]{{.*}}4{{.*}}4184; DEBUG: err @ dot.c:83185; STRIPPED-NOT: err @ dot.c:83186define i32 @caller() #1 {187  %1 = alloca i32, align 4188  %2 = alloca i32, align 4189  %3 = alloca ptr, align 8190  %4 = alloca ptr, align 8191  %5 = alloca ptr, align 8192  %6 = alloca i32, align 4193  %7 = alloca i32, align 4194  call void @llvm.dbg.declare(metadata ptr %2, metadata !81, metadata !DIExpression()), !dbg !85195  call void @llvm.dbg.declare(metadata ptr %3, metadata !86, metadata !DIExpression()), !dbg !87196  call void @llvm.dbg.declare(metadata ptr %4, metadata !88, metadata !DIExpression()), !dbg !89197  store ptr null, ptr %4, align 8198  call void @llvm.dbg.declare(metadata ptr %5, metadata !90, metadata !DIExpression()), !dbg !91199  call void @llvm.dbg.declare(metadata ptr %6, metadata !92, metadata !DIExpression()), !dbg !93200  call void @llvm.dbg.declare(metadata ptr %7, metadata !94, metadata !DIExpression()), !dbg !95201  %8 = call i32 @do_work(ptr %3, ptr null, ptr null)202  store i32 0, ptr %6, align 4203  store i32 0, ptr %1, align 4204  call void @cleanup_result(ptr %5)205  ret i32 0206}207 208; test29b: An array of [5 x i8] and a requested ssp-buffer-size of 5.209; Requires protector.210; Function Attrs: ssp stack-protector-buffer-size=5211; BOTH: Function: test29b212; BOTH:  [SP-4]{{.+}}Spill{{.*}}4{{.+}}4213; BOTH:  [SP-8]{{.+}}Spill{{.*}}4{{.+}}4214; BOTH:  [SP-12]{{.+}}Protector{{.*}}4{{.+}}4215; BOTH:  [SP-20]{{.+}}4{{.+}}5216define i32 @test29b() #2 {217entry:218  %test = alloca [5 x i8], align 1219  %call = call i32 (ptr, ...) @printf(ptr @.str, ptr %test)220  ret i32 %call221}222 223 224; uselistorder directives225uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 18 }226 227attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }228attributes #1 = { "frame-pointer"="all" }229attributes #2 = { ssp "stack-protector-buffer-size"="5" "frame-pointer"="all" }230attributes #3 = { "frame-pointer"="none" }231 232!llvm.dbg.cu = !{!0, !2}233!llvm.module.flags = !{!18, !19, !20, !21, !22, !23, !24}234 235!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)236!1 = !DIFile(filename: "frame-diags.c", directory: "")237!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None)238!3 = !DIFile(filename: "dot.c", directory: "")239!4 = !{!5, !6, !10, !13}240!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)241!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)242!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8)243!8 = !{!9, !12}244!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64)245!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)246!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)247!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64)248!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)249!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15)250!15 = !{!16, !17}251!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64)252!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64)253!18 = !{i32 7, !"Dwarf Version", i32 5}254!19 = !{i32 2, !"Debug Info Version", i32 3}255!20 = !{i32 1, !"wchar_size", i32 4}256!21 = !{i32 8, !"PIC Level", i32 2}257!22 = !{i32 7, !"PIE Level", i32 2}258!23 = !{i32 7, !"uwtable", i32 2}259!24 = !{i32 7, !"frame-pointer", i32 2}260!25 = !DILocalVariable(name: "buffer", scope: !26, file: !1, line: 30, type: !32)261!26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 29, column: 3)262!27 = distinct !DISubprogram(name: "stackSizeWarning", scope: !1, file: !1, line: 28, type: !28, scopeLine: 28, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !30)263!28 = !DISubroutineType(types: !29)264!29 = !{null}265!30 = !{!25, !31, !36, !37}266!31 = !DILocalVariable(name: "buffer2", scope: !27, file: !1, line: 33, type: !32)267!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 640, elements: !34)268!33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)269!34 = !{!35}270!35 = !DISubrange(count: 80)271!36 = !DILocalVariable(name: "a", scope: !27, file: !1, line: 34, type: !11)272!37 = !DILocalVariable(name: "b", scope: !27, file: !1, line: 35, type: !38)273!38 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)274!39 = !DILocation(line: 30, column: 10, scope: !26)275!40 = !DILocation(line: 33, column: 8, scope: !27)276!41 = !DILocalVariable(name: "a", arg: 1, scope: !42, file: !3, line: 13, type: !6)277!42 = distinct !DISubprogram(name: "cleanup_array", scope: !3, file: !3, line: 13, type: !43, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)278!43 = !DISubroutineType(types: !44)279!44 = !{null, !6}280!45 = !{}281!46 = !DILocation(line: 13, column: 34, scope: !42)282!47 = !DILocalVariable(name: "res", arg: 1, scope: !48, file: !3, line: 21, type: !13)283!48 = distinct !DISubprogram(name: "cleanup_result", scope: !3, file: !3, line: 21, type: !49, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)284!49 = !DISubroutineType(types: !50)285!50 = !{null, !13}286!51 = !DILocation(line: 21, column: 36, scope: !48)287!52 = !DILocalVariable(name: "A", arg: 1, scope: !53, file: !3, line: 32, type: !6)288!53 = distinct !DISubprogram(name: "do_work", scope: !3, file: !3, line: 32, type: !54, scopeLine: 32, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)289!54 = !DISubroutineType(types: !55)290!55 = !{!11, !6, !6, !13}291!56 = !DILocation(line: 32, column: 27, scope: !53)292!57 = !DILocalVariable(name: "B", arg: 2, scope: !53, file: !3, line: 32, type: !6)293!58 = !DILocation(line: 32, column: 44, scope: !53)294!59 = !DILocalVariable(name: "out", arg: 3, scope: !53, file: !3, line: 32, type: !13)295!60 = !DILocation(line: 32, column: 62, scope: !53)296!61 = !DILocalVariable(name: "len", scope: !53, file: !3, line: 37, type: !62)297!62 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)298!63 = !DILocation(line: 37, column: 13, scope: !53)299!64 = !DILocalVariable(name: "AB", scope: !53, file: !3, line: 38, type: !6)300!65 = !DILocation(line: 38, column: 17, scope: !53)301!66 = !DILocalVariable(name: "sum", scope: !53, file: !3, line: 54, type: !11)302!67 = !DILocation(line: 54, column: 7, scope: !53)303!68 = !DILocalVariable(name: "i", scope: !69, file: !3, line: 55, type: !11)304!69 = distinct !DILexicalBlock(scope: !53, file: !3, line: 55, column: 3)305!70 = !DILocation(line: 55, column: 12, scope: !69)306!71 = !DILocalVariable(name: "size", arg: 1, scope: !72, file: !3, line: 62, type: !11)307!72 = distinct !DISubprogram(name: "gen_array", scope: !3, file: !3, line: 62, type: !73, scopeLine: 62, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)308!73 = !DISubroutineType(types: !74)309!74 = !{!6, !11}310!75 = !DILocation(line: 62, column: 29, scope: !72)311!76 = !DILocalVariable(name: "res", scope: !72, file: !3, line: 65, type: !6)312!77 = !DILocation(line: 65, column: 17, scope: !72)313!78 = !DILocalVariable(name: "i", scope: !79, file: !3, line: 69, type: !11)314!79 = distinct !DILexicalBlock(scope: !72, file: !3, line: 69, column: 3)315!80 = !DILocation(line: 69, column: 12, scope: !79)316!81 = !DILocalVariable(name: "size", scope: !82, file: !3, line: 77, type: !62)317!82 = distinct !DISubprogram(name: "caller", scope: !3, file: !3, line: 76, type: !83, scopeLine: 76, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)318!83 = !DISubroutineType(types: !84)319!84 = !{!11}320!85 = !DILocation(line: 77, column: 13, scope: !82)321!86 = !DILocalVariable(name: "A", scope: !82, file: !3, line: 78, type: !6)322!87 = !DILocation(line: 78, column: 17, scope: !82)323!88 = !DILocalVariable(name: "B", scope: !82, file: !3, line: 79, type: !6)324!89 = !DILocation(line: 79, column: 17, scope: !82)325!90 = !DILocalVariable(name: "res", scope: !82, file: !3, line: 80, type: !13)326!91 = !DILocation(line: 80, column: 18, scope: !82)327!92 = !DILocalVariable(name: "ret", scope: !82, file: !3, line: 81, type: !11)328!93 = !DILocation(line: 81, column: 7, scope: !82)329!94 = !DILocalVariable(name: "err", scope: !82, file: !3, line: 83, type: !11)330!95 = !DILocation(line: 83, column: 7, scope: !82)331