• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -enable-shrink-wrap=true < %s | FileCheck %s --check-prefix=ASM
2; RUN: llc -enable-shrink-wrap=true -filetype=obj < %s | llvm-readobj -codeview | FileCheck %s --check-prefix=OBJ
3
4; C source:
5; int doSomething(int*);
6; int __fastcall shrink_wrap_basic(int a, int b, int c, int d) {
7;   if (a < b)
8;     return a;
9;   for (int i = c; i < d; ++i)
10;     doSomething(&c);
11;   return doSomething(&c);
12; }
13
14; ASM: @shrink_wrap_basic@16:                  # @"\01@shrink_wrap_basic@16"
15; ASM:         .cv_fpo_proc    @shrink_wrap_basic@16 8
16; ASM:         .cv_loc 0 1 3 9                 # t.c:3:9
17; ASM:         movl    %ecx, %eax
18; ASM:         cmpl    %edx, %ecx
19; ASM:         jl      [[EPILOGUE:LBB0_[0-9]+]]
20
21; ASM:         pushl   %ebx
22; ASM:         .cv_fpo_pushreg %ebx
23; ASM:         pushl   %edi
24; ASM:         .cv_fpo_pushreg %edi
25; ASM:         pushl   %esi
26; ASM:         .cv_fpo_pushreg %esi
27; ASM:         .cv_fpo_endprologue
28
29; ASM:         calll   _doSomething
30
31; ASM:         popl    %esi
32; ASM:         popl    %edi
33; ASM:         popl    %ebx
34; ASM: [[EPILOGUE]]:                                 # %return
35; ASM:         retl    $8
36; ASM: Ltmp11:
37; ASM:         .cv_fpo_endproc
38
39; Note how RvaStart advances 7 bytes to skip the shrink-wrapped portion.
40; OBJ: SubSectionType: FrameData (0xF5)
41; OBJ:    FrameData {
42; OBJ:      RvaStart: 0x0
43; OBJ:      CodeSize: 0x34
44; OBJ:      FrameFunc: $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + =
45; OBJ:      PrologSize: 0x9
46; OBJ:    }
47; OBJ:    FrameData {
48; OBJ:      RvaStart: 0x7
49; OBJ:      CodeSize: 0x2D
50; OBJ:      FrameFunc: $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebx $T0 4 - ^ =
51; OBJ:      PrologSize: 0x2
52; OBJ:    }
53; OBJ:    FrameData {
54; OBJ:      RvaStart: 0x8
55; OBJ:      CodeSize: 0x2C
56; OBJ:      FrameFunc: $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebx $T0 4 - ^ = $edi $T0 8 - ^ =
57; OBJ:      PrologSize: 0x1
58; OBJ:    }
59; OBJ:    FrameData {
60; OBJ:      RvaStart: 0x9
61; OBJ:      CodeSize: 0x2B
62; OBJ:      FrameFunc: $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebx $T0 4 - ^ = $edi $T0 8 - ^ = $esi $T0 12 - ^ =
63; OBJ:      PrologSize: 0x0
64; OBJ:    }
65; OBJ-NOT: FrameData
66
67; ModuleID = 't.c'
68source_filename = "t.c"
69target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
70target triple = "i386-pc-windows-msvc19.11.25508"
71
72; Function Attrs: nounwind
73define x86_fastcallcc i32 @"\01@shrink_wrap_basic@16"(i32 inreg %a, i32 inreg %b, i32 %c, i32 %d) local_unnamed_addr #0 !dbg !8 {
74entry:
75  %c.addr = alloca i32, align 4
76  tail call void @llvm.dbg.value(metadata i32 %d, metadata !13, metadata !DIExpression()), !dbg !19
77  tail call void @llvm.dbg.value(metadata i32 %c, metadata !14, metadata !DIExpression()), !dbg !20
78  store i32 %c, i32* %c.addr, align 4, !tbaa !21
79  tail call void @llvm.dbg.value(metadata i32 %b, metadata !15, metadata !DIExpression()), !dbg !25
80  tail call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !26
81  %cmp = icmp slt i32 %a, %b, !dbg !27
82  br i1 %cmp, label %return, label %for.cond.preheader, !dbg !29
83
84for.cond.preheader:                               ; preds = %entry
85  br label %for.cond, !dbg !30
86
87for.cond:                                         ; preds = %for.cond.preheader, %for.cond
88  %i.0 = phi i32 [ %inc, %for.cond ], [ %c, %for.cond.preheader ]
89  call void @llvm.dbg.value(metadata i32 %i.0, metadata !17, metadata !DIExpression()), !dbg !32
90  %cmp1 = icmp slt i32 %i.0, %d, !dbg !30
91  call void @llvm.dbg.value(metadata i32* %c.addr, metadata !14, metadata !DIExpression()), !dbg !20
92  %call = call i32 @doSomething(i32* nonnull %c.addr) #3, !dbg !33
93  %inc = add nsw i32 %i.0, 1, !dbg !34
94  call void @llvm.dbg.value(metadata i32 %inc, metadata !17, metadata !DIExpression()), !dbg !32
95  br i1 %cmp1, label %for.cond, label %return, !dbg !35, !llvm.loop !36
96
97return:                                           ; preds = %for.cond, %entry
98  %retval.0 = phi i32 [ %a, %entry ], [ %call, %for.cond ]
99  ret i32 %retval.0, !dbg !38
100}
101
102declare i32 @doSomething(i32*) local_unnamed_addr #1
103
104; Function Attrs: nounwind readnone speculatable
105declare void @llvm.dbg.value(metadata, metadata, metadata) #2
106
107attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
108attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
109attributes #2 = { nounwind readnone speculatable }
110attributes #3 = { nounwind }
111
112!llvm.dbg.cu = !{!0}
113!llvm.module.flags = !{!3, !4, !5, !6}
114!llvm.ident = !{!7}
115
116!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
117!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "32f118fd5dd7e65ff7733c49b2f804ef")
118!2 = !{}
119!3 = !{i32 1, !"NumRegisterParameters", i32 0}
120!4 = !{i32 2, !"CodeView", i32 1}
121!5 = !{i32 2, !"Debug Info Version", i32 3}
122!6 = !{i32 1, !"wchar_size", i32 2}
123!7 = !{!"clang version 6.0.0 "}
124!8 = distinct !DISubprogram(name: "shrink_wrap_basic", linkageName: "\01@shrink_wrap_basic@16", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
125!9 = !DISubroutineType(cc: DW_CC_BORLAND_msfastcall, types: !10)
126!10 = !{!11, !11, !11, !11, !11}
127!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
128!12 = !{!13, !14, !15, !16, !17}
129!13 = !DILocalVariable(name: "d", arg: 4, scope: !8, file: !1, line: 2, type: !11)
130!14 = !DILocalVariable(name: "c", arg: 3, scope: !8, file: !1, line: 2, type: !11)
131!15 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 2, type: !11)
132!16 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 2, type: !11)
133!17 = !DILocalVariable(name: "i", scope: !18, file: !1, line: 5, type: !11)
134!18 = distinct !DILexicalBlock(scope: !8, file: !1, line: 5, column: 3)
135!19 = !DILocation(line: 2, column: 59, scope: !8)
136!20 = !DILocation(line: 2, column: 52, scope: !8)
137!21 = !{!22, !22, i64 0}
138!22 = !{!"int", !23, i64 0}
139!23 = !{!"omnipotent char", !24, i64 0}
140!24 = !{!"Simple C/C++ TBAA"}
141!25 = !DILocation(line: 2, column: 45, scope: !8)
142!26 = !DILocation(line: 2, column: 38, scope: !8)
143!27 = !DILocation(line: 3, column: 9, scope: !28)
144!28 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
145!29 = !DILocation(line: 3, column: 7, scope: !8)
146!30 = !DILocation(line: 5, column: 21, scope: !31)
147!31 = distinct !DILexicalBlock(scope: !18, file: !1, line: 5, column: 3)
148!32 = !DILocation(line: 5, column: 12, scope: !18)
149!33 = !DILocation(line: 0, scope: !8)
150!34 = !DILocation(line: 5, column: 26, scope: !31)
151!35 = !DILocation(line: 5, column: 3, scope: !18)
152!36 = distinct !{!36, !35, !37}
153!37 = !DILocation(line: 6, column: 19, scope: !18)
154!38 = !DILocation(line: 8, column: 1, scope: !8)
155