brintos

brintos / llvm-project-archived public Read only

0
0
Text · 15.3 KiB · cfc493a Raw
316 lines · plain
1; Test remark output for stack-frame-layout2 3; ensure basic output works4; RUN: llc -mcpu=corei7 -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 -mcpu=corei7 -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=i686-unknown-linux 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=i686-unknown-linux 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: Offset: [SP-88], Type: Variable, Align: 16, Size: 8022; CHECK:    buffer @ frame-diags.c:3023; NO_COLORING: Offset: [SP-168], Type: Variable, Align: 16, Size: 8024; CHECK:    buffer2 @ frame-diags.c:3325define void @stackSizeWarning() {26entry:27  %buffer = alloca [80 x i8], align 1628  %buffer2 = alloca [80 x i8], align 1629  call void @llvm.dbg.declare(metadata ptr %buffer, metadata !25, metadata !DIExpression()), !dbg !3930  call void @llvm.dbg.declare(metadata ptr %buffer2, metadata !31, metadata !DIExpression()), !dbg !4031  ret void32}33 34; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn35declare void @llvm.dbg.declare(metadata, metadata, metadata) #036 37; BOTH: Function: cleanup_array38; BOTH-NEXT:  Offset: [SP+4], Type: Fixed, Align: 16, Size: 439; DEBUG: a @ dot.c:1340; STRIPPED-NOT: a @ dot.c:1341; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 442define void @cleanup_array(ptr %0) #1 {43  %2 = alloca ptr, align 844  store ptr %0, ptr %2, align 845  call void @llvm.dbg.declare(metadata ptr %2, metadata !41, metadata !DIExpression()), !dbg !4646  ret void47}48 49; BOTH: Function: cleanup_result50; BOTH:  Offset: [SP+4], Type: Fixed, Align: 16, Size: 451; DEBUG: res @ dot.c:2152; STRIPPED-NOT: res @ dot.c:2153; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 454define void @cleanup_result(ptr %0) #1 {55  %2 = alloca ptr, align 856  store ptr %0, ptr %2, align 857  call void @llvm.dbg.declare(metadata ptr %2, metadata !47, metadata !DIExpression()), !dbg !5158  ret void59}60 61; BOTH: Function: do_work62; BOTH:  Offset: [SP+12], Type: Fixed, Align: 8, Size: 463; DEBUG: out @ dot.c:3264; STRIPPED-NOT: out @ dot.c:3265; BOTH:  Offset: [SP+8], Type: Fixed, Align: 4, Size: 466; BOTH:  Offset: [SP+4], Type: Fixed, Align: 16, Size: 467; DEBUG: A @ dot.c:3268; STRIPPED-NOT: A @ dot.c:3269; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 470; BOTH:  Offset: [SP-12], Type: Variable, Align: 8, Size: 471; DEBUG: AB @ dot.c:3872; STRIPPED-NOT: AB @ dot.c:3873; BOTH:  Offset: [SP-16], Type: Variable, Align: 4, Size: 474; DEBUG: i @ dot.c:5575; STRIPPED-NOT: i @ dot.c:5576; BOTH:  Offset: [SP-20], Type: Variable, Align: 8, Size: 477; DEBUG: B @ dot.c:3278; STRIPPED-NOT: B @ dot.c:3279; BOTH:  Offset: [SP-24], Type: Variable, Align: 4, Size: 480; DEBUG: len @ dot.c:3781; STRIPPED-NOT: len @ dot.c:3782; BOTH:  Offset: [SP-28], Type: Variable, Align: 4, Size: 483; BOTH:  Offset: [SP-32], Type: Variable, Align: 4, Size: 484; DEBUG: sum @ dot.c:5485; STRIPPED-NOT: sum @ dot.c:5486define i32 @do_work(ptr %0, ptr %1, ptr %2) #2 {87  %4 = alloca i32, align 488  %5 = alloca ptr, align 889  %6 = alloca ptr, align 890  %7 = alloca ptr, align 891  %8 = alloca i32, align 492  %9 = alloca ptr, align 893  %10 = alloca i32, align 494  %11 = alloca i32, align 495  store ptr %0, ptr %5, align 896  call void @llvm.dbg.declare(metadata ptr %5, metadata !52, metadata !DIExpression()), !dbg !5697  call void @llvm.dbg.declare(metadata ptr %6, metadata !57, metadata !DIExpression()), !dbg !5898  store ptr %2, ptr %7, align 899  call void @llvm.dbg.declare(metadata ptr %7, metadata !59, metadata !DIExpression()), !dbg !60100  call void @llvm.dbg.declare(metadata ptr %8, metadata !61, metadata !DIExpression()), !dbg !63101  call void @llvm.dbg.declare(metadata ptr %9, metadata !64, metadata !DIExpression()), !dbg !65102  store ptr null, ptr %9, align 8103  store ptr null, ptr null, align 8104  store i32 0, ptr %9, align 8105  %12 = load i32, ptr %8, align 4106  store i32 %12, ptr null, align 8107  call void @llvm.dbg.declare(metadata ptr %10, metadata !66, metadata !DIExpression()), !dbg !67108  call void @llvm.dbg.declare(metadata ptr %11, metadata !68, metadata !DIExpression()), !dbg !70109  store i32 0, ptr %11, align 4110  br label %13111 11213:                                               ; preds = %16, %3113  %14 = load i32, ptr %11, align 4114  %15 = icmp slt i32 %14, 0115  br i1 %15, label %16, label %18116 11716:                                               ; preds = %13118  %17 = load i32, ptr %6, align 4119  store i32 %17, ptr null, align 4120  br label %13121 12218:                                               ; preds = %13123  store i32 0, ptr %4, align 4124  ret i32 0125}126 127; BOTH: Function: gen_array128; BOTH:  Offset: [SP+4], Type: Fixed, Align: 16, Size: 4129; DEBUG: size @ dot.c:62130; STRIPPED-NOT: size @ dot.c:62131; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 4132; BOTH:  Offset: [SP-12], Type: Variable, Align: 8, Size: 4133; DEBUG: res @ dot.c:65134; STRIPPED-NOT: res @ dot.c:65135; BOTH:  Offset: [SP-16], Type: Variable, Align: 4, Size: 4136; DEBUG: i @ dot.c:69137; STRIPPED-NOT: i @ dot.c:69138; BOTH:  Offset: [SP-20], Type: Variable, Align: 8, Size: 4139define ptr @gen_array(i32 %0) #1 {140  %2 = alloca ptr, align 8141  %3 = alloca i32, align 4142  %4 = alloca ptr, align 8143  %5 = alloca i32, align 4144  store i32 %0, ptr %3, align 4145  call void @llvm.dbg.declare(metadata ptr %3, metadata !71, metadata !DIExpression()), !dbg !75146  call void @llvm.dbg.declare(metadata ptr %4, metadata !76, metadata !DIExpression()), !dbg !77147  store ptr null, ptr %4, align 8148  call void @llvm.dbg.declare(metadata ptr %5, metadata !78, metadata !DIExpression()), !dbg !80149  store i32 0, ptr %5, align 4150  ret ptr null151}152 153; BOTH: Function: caller154; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 4155; BOTH:  Offset: [SP-12], Type: Variable, Align: 8, Size: 4156; DEBUG: res @ dot.c:80157; STRIPPED-NOT: res @ dot.c:80158; BOTH:  Offset: [SP-20], Type: Variable, Align: 8, Size: 4159; DEBUG: B @ dot.c:79160; STRIPPED-NOT: B @ dot.c:79161; BOTH:  Offset: [SP-28], Type: Variable, Align: 8, Size: 4162; DEBUG: A @ dot.c:78163; STRIPPED-NOT: A @ dot.c:78164; BOTH:  Offset: [SP-32], Type: Variable, Align: 4, Size: 4165; DEBUG: ret @ dot.c:81166; STRIPPED-NOT: ret @ dot.c:81167; BOTH:  Offset: [SP-36], Type: Variable, Align: 4, Size: 4168; BOTH:  Offset: [SP-40], Type: Variable, Align: 4, Size: 4169; DEBUG: err @ dot.c:83170; STRIPPED-NOT: err @ dot.c:83171; BOTH:  Offset: [SP-44], Type: Variable, Align: 4, Size: 4172; DEBUG:  size @ dot.c:77173; STRIPPED-NOT: size @ dot.c:77174define i32 @caller() #1 {175  %1 = alloca i32, align 4176  %2 = alloca i32, align 4177  %3 = alloca ptr, align 8178  %4 = alloca ptr, align 8179  %5 = alloca ptr, align 8180  %6 = alloca i32, align 4181  %7 = alloca i32, align 4182  call void @llvm.dbg.declare(metadata ptr %2, metadata !81, metadata !DIExpression()), !dbg !85183  call void @llvm.dbg.declare(metadata ptr %3, metadata !86, metadata !DIExpression()), !dbg !87184  call void @llvm.dbg.declare(metadata ptr %4, metadata !88, metadata !DIExpression()), !dbg !89185  store ptr null, ptr %4, align 8186  call void @llvm.dbg.declare(metadata ptr %5, metadata !90, metadata !DIExpression()), !dbg !91187  call void @llvm.dbg.declare(metadata ptr %6, metadata !92, metadata !DIExpression()), !dbg !93188  call void @llvm.dbg.declare(metadata ptr %7, metadata !94, metadata !DIExpression()), !dbg !95189  %8 = call i32 @do_work(ptr %3, ptr null, ptr null)190  store i32 0, ptr %6, align 4191  store i32 0, ptr %1, align 4192  call void @cleanup_result(ptr %5)193  ret i32 0194}195 196; test29b: An array of [5 x i8] and a requested ssp-buffer-size of 5.197; Requires protector.198; Function Attrs: ssp stack-protector-buffer-size=5199; BOTH: Function: test29b200; BOTH:  Offset: [SP-4], Type: Spill, Align: 8, Size: 4201; BOTH:  Offset: [SP-8], Type: Protector, Align: 4, Size: 4202; BOTH:  Offset: [SP-13], Type: Variable, Align: 1, Size: 5203define i32 @test29b() #2 {204entry:205  %test = alloca [5 x i8], align 1206  %call = call i32 (ptr, ...) @printf(ptr @.str, ptr %test)207  ret i32 %call208}209 210; uselistorder directives211uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 18 }212 213attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }214attributes #1 = { "frame-pointer"="all" }215attributes #2 = { ssp "stack-protector-buffer-size"="5" "frame-pointer"="all" }216 217!llvm.dbg.cu = !{!0, !2}218!llvm.module.flags = !{!18, !19, !20, !21, !22, !23, !24}219 220!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)221!1 = !DIFile(filename: "frame-diags.c", directory: "")222!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, nameTableKind: None)223!3 = !DIFile(filename: "dot.c", directory: "")224!4 = !{!5, !6, !10, !13}225!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)226!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)227!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Array", file: !3, line: 3, size: 128, elements: !8)228!8 = !{!9, !12}229!9 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !7, file: !3, line: 4, baseType: !10, size: 64)230!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)231!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)232!12 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !7, file: !3, line: 5, baseType: !11, size: 32, offset: 64)233!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)234!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Result", file: !3, line: 8, size: 128, elements: !15)235!15 = !{!16, !17}236!16 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !14, file: !3, line: 9, baseType: !6, size: 64)237!17 = !DIDerivedType(tag: DW_TAG_member, name: "sum", scope: !14, file: !3, line: 10, baseType: !11, size: 32, offset: 64)238!18 = !{i32 7, !"Dwarf Version", i32 5}239!19 = !{i32 2, !"Debug Info Version", i32 3}240!20 = !{i32 1, !"wchar_size", i32 4}241!21 = !{i32 8, !"PIC Level", i32 2}242!22 = !{i32 7, !"PIE Level", i32 2}243!23 = !{i32 7, !"uwtable", i32 2}244!24 = !{i32 7, !"frame-pointer", i32 2}245!25 = !DILocalVariable(name: "buffer", scope: !26, file: !1, line: 30, type: !32)246!26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 29, column: 3)247!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)248!28 = !DISubroutineType(types: !29)249!29 = !{null}250!30 = !{!25, !31, !36, !37}251!31 = !DILocalVariable(name: "buffer2", scope: !27, file: !1, line: 33, type: !32)252!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 640, elements: !34)253!33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)254!34 = !{!35}255!35 = !DISubrange(count: 80)256!36 = !DILocalVariable(name: "a", scope: !27, file: !1, line: 34, type: !11)257!37 = !DILocalVariable(name: "b", scope: !27, file: !1, line: 35, type: !38)258!38 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)259!39 = !DILocation(line: 30, column: 10, scope: !26)260!40 = !DILocation(line: 33, column: 8, scope: !27)261!41 = !DILocalVariable(name: "a", arg: 1, scope: !42, file: !3, line: 13, type: !6)262!42 = distinct !DISubprogram(name: "cleanup_array", scope: !3, file: !3, line: 13, type: !43, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)263!43 = !DISubroutineType(types: !44)264!44 = !{null, !6}265!45 = !{}266!46 = !DILocation(line: 13, column: 34, scope: !42)267!47 = !DILocalVariable(name: "res", arg: 1, scope: !48, file: !3, line: 21, type: !13)268!48 = distinct !DISubprogram(name: "cleanup_result", scope: !3, file: !3, line: 21, type: !49, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)269!49 = !DISubroutineType(types: !50)270!50 = !{null, !13}271!51 = !DILocation(line: 21, column: 36, scope: !48)272!52 = !DILocalVariable(name: "A", arg: 1, scope: !53, file: !3, line: 32, type: !6)273!53 = distinct !DISubprogram(name: "do_work", scope: !3, file: !3, line: 32, type: !54, scopeLine: 32, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)274!54 = !DISubroutineType(types: !55)275!55 = !{!11, !6, !6, !13}276!56 = !DILocation(line: 32, column: 27, scope: !53)277!57 = !DILocalVariable(name: "B", arg: 2, scope: !53, file: !3, line: 32, type: !6)278!58 = !DILocation(line: 32, column: 44, scope: !53)279!59 = !DILocalVariable(name: "out", arg: 3, scope: !53, file: !3, line: 32, type: !13)280!60 = !DILocation(line: 32, column: 62, scope: !53)281!61 = !DILocalVariable(name: "len", scope: !53, file: !3, line: 37, type: !62)282!62 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)283!63 = !DILocation(line: 37, column: 13, scope: !53)284!64 = !DILocalVariable(name: "AB", scope: !53, file: !3, line: 38, type: !6)285!65 = !DILocation(line: 38, column: 17, scope: !53)286!66 = !DILocalVariable(name: "sum", scope: !53, file: !3, line: 54, type: !11)287!67 = !DILocation(line: 54, column: 7, scope: !53)288!68 = !DILocalVariable(name: "i", scope: !69, file: !3, line: 55, type: !11)289!69 = distinct !DILexicalBlock(scope: !53, file: !3, line: 55, column: 3)290!70 = !DILocation(line: 55, column: 12, scope: !69)291!71 = !DILocalVariable(name: "size", arg: 1, scope: !72, file: !3, line: 62, type: !11)292!72 = distinct !DISubprogram(name: "gen_array", scope: !3, file: !3, line: 62, type: !73, scopeLine: 62, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)293!73 = !DISubroutineType(types: !74)294!74 = !{!6, !11}295!75 = !DILocation(line: 62, column: 29, scope: !72)296!76 = !DILocalVariable(name: "res", scope: !72, file: !3, line: 65, type: !6)297!77 = !DILocation(line: 65, column: 17, scope: !72)298!78 = !DILocalVariable(name: "i", scope: !79, file: !3, line: 69, type: !11)299!79 = distinct !DILexicalBlock(scope: !72, file: !3, line: 69, column: 3)300!80 = !DILocation(line: 69, column: 12, scope: !79)301!81 = !DILocalVariable(name: "size", scope: !82, file: !3, line: 77, type: !62)302!82 = distinct !DISubprogram(name: "caller", scope: !3, file: !3, line: 76, type: !83, scopeLine: 76, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45)303!83 = !DISubroutineType(types: !84)304!84 = !{!11}305!85 = !DILocation(line: 77, column: 13, scope: !82)306!86 = !DILocalVariable(name: "A", scope: !82, file: !3, line: 78, type: !6)307!87 = !DILocation(line: 78, column: 17, scope: !82)308!88 = !DILocalVariable(name: "B", scope: !82, file: !3, line: 79, type: !6)309!89 = !DILocation(line: 79, column: 17, scope: !82)310!90 = !DILocalVariable(name: "res", scope: !82, file: !3, line: 80, type: !13)311!91 = !DILocation(line: 80, column: 18, scope: !82)312!92 = !DILocalVariable(name: "ret", scope: !82, file: !3, line: 81, type: !11)313!93 = !DILocation(line: 81, column: 7, scope: !82)314!94 = !DILocalVariable(name: "err", scope: !82, file: !3, line: 83, type: !11)315!95 = !DILocation(line: 83, column: 7, scope: !82)316