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
5 ; int doSomething(int*);
6 ; int __fastcall shrink_wrap_basic(int a, int b, int c, int d) {
9 ; for (int i = c; i < d; ++i)
11 ; return doSomething(&c);
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]+]]
22 ; ASM: .cv_fpo_pushreg %ebx
24 ; ASM: .cv_fpo_pushreg %edi
26 ; ASM: .cv_fpo_pushreg %esi
27 ; ASM: .cv_fpo_endprologue
29 ; ASM: calll _doSomething
34 ; ASM: [[EPILOGUE]]: # %return
37 ; ASM: .cv_fpo_endproc
39 ; Note how RvaStart advances 7 bytes to skip the shrink-wrapped portion.
40 ; OBJ: SubSectionType: FrameData (0xF5)
44 ; OBJ: PrologSize: 0x9
46 ; OBJ-NEXT: $T0 .raSearch =
47 ; OBJ-NEXT: $eip $T0 ^ =
48 ; OBJ-NEXT: $esp $T0 4 + =
54 ; OBJ: PrologSize: 0x2
56 ; OBJ-NEXT: $T0 .raSearch =
57 ; OBJ-NEXT: $eip $T0 ^ =
58 ; OBJ-NEXT: $esp $T0 4 + =
59 ; OBJ-NEXT: $ebx $T0 4 - ^ =
65 ; OBJ: PrologSize: 0x1
67 ; OBJ-NEXT: $T0 .raSearch =
68 ; OBJ-NEXT: $eip $T0 ^ =
69 ; OBJ-NEXT: $esp $T0 4 + =
70 ; OBJ-NEXT: $ebx $T0 4 - ^ =
71 ; OBJ-NEXT: $edi $T0 8 - ^ =
77 ; OBJ: PrologSize: 0x0
79 ; OBJ-NEXT: $T0 .raSearch =
80 ; OBJ-NEXT: $eip $T0 ^ =
81 ; OBJ-NEXT: $esp $T0 4 + =
82 ; OBJ-NEXT: $ebx $T0 4 - ^ =
83 ; OBJ-NEXT: $edi $T0 8 - ^ =
84 ; OBJ-NEXT: $esi $T0 12 - ^ =
90 source_filename = "t.c"
91 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
92 target triple = "i386-pc-windows-msvc19.11.25508"
94 ; Function Attrs: nounwind
95 define x86_fastcallcc i32 @"\01@shrink_wrap_basic@16"(i32 inreg %a, i32 inreg %b, i32 %c, i32 %d) local_unnamed_addr #0 !dbg !8 {
97 %c.addr = alloca i32, align 4
98 tail call void @llvm.dbg.value(metadata i32 %d, metadata !13, metadata !DIExpression()), !dbg !19
99 tail call void @llvm.dbg.value(metadata i32 %c, metadata !14, metadata !DIExpression()), !dbg !20
100 store i32 %c, i32* %c.addr, align 4, !tbaa !21
101 tail call void @llvm.dbg.value(metadata i32 %b, metadata !15, metadata !DIExpression()), !dbg !25
102 tail call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !26
103 %cmp = icmp slt i32 %a, %b, !dbg !27
104 br i1 %cmp, label %return, label %for.cond.preheader, !dbg !29
106 for.cond.preheader: ; preds = %entry
107 br label %for.cond, !dbg !30
109 for.cond: ; preds = %for.cond.preheader, %for.cond
110 %i.0 = phi i32 [ %inc, %for.cond ], [ %c, %for.cond.preheader ]
111 call void @llvm.dbg.value(metadata i32 %i.0, metadata !17, metadata !DIExpression()), !dbg !32
112 %cmp1 = icmp slt i32 %i.0, %d, !dbg !30
113 call void @llvm.dbg.value(metadata i32* %c.addr, metadata !14, metadata !DIExpression()), !dbg !20
114 %call = call i32 @doSomething(i32* nonnull %c.addr) #3, !dbg !33
115 %inc = add nsw i32 %i.0, 1, !dbg !34
116 call void @llvm.dbg.value(metadata i32 %inc, metadata !17, metadata !DIExpression()), !dbg !32
117 br i1 %cmp1, label %for.cond, label %return, !dbg !35, !llvm.loop !36
119 return: ; preds = %for.cond, %entry
120 %retval.0 = phi i32 [ %a, %entry ], [ %call, %for.cond ]
121 ret i32 %retval.0, !dbg !38
124 declare i32 @doSomething(i32*) local_unnamed_addr #1
126 ; Function Attrs: nounwind readnone speculatable
127 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
129 attributes #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" }
130 attributes #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" }
131 attributes #2 = { nounwind readnone speculatable }
132 attributes #3 = { nounwind }
135 !llvm.module.flags = !{!3, !4, !5, !6}
138 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
139 !1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "32f118fd5dd7e65ff7733c49b2f804ef")
141 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
142 !4 = !{i32 2, !"CodeView", i32 1}
143 !5 = !{i32 2, !"Debug Info Version", i32 3}
144 !6 = !{i32 1, !"wchar_size", i32 2}
145 !7 = !{!"clang version 6.0.0 "}
146 !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)
147 !9 = !DISubroutineType(cc: DW_CC_BORLAND_msfastcall, types: !10)
148 !10 = !{!11, !11, !11, !11, !11}
149 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
150 !12 = !{!13, !14, !15, !16, !17}
151 !13 = !DILocalVariable(name: "d", arg: 4, scope: !8, file: !1, line: 2, type: !11)
152 !14 = !DILocalVariable(name: "c", arg: 3, scope: !8, file: !1, line: 2, type: !11)
153 !15 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 2, type: !11)
154 !16 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 2, type: !11)
155 !17 = !DILocalVariable(name: "i", scope: !18, file: !1, line: 5, type: !11)
156 !18 = distinct !DILexicalBlock(scope: !8, file: !1, line: 5, column: 3)
157 !19 = !DILocation(line: 2, column: 59, scope: !8)
158 !20 = !DILocation(line: 2, column: 52, scope: !8)
159 !21 = !{!22, !22, i64 0}
160 !22 = !{!"int", !23, i64 0}
161 !23 = !{!"omnipotent char", !24, i64 0}
162 !24 = !{!"Simple C/C++ TBAA"}
163 !25 = !DILocation(line: 2, column: 45, scope: !8)
164 !26 = !DILocation(line: 2, column: 38, scope: !8)
165 !27 = !DILocation(line: 3, column: 9, scope: !28)
166 !28 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
167 !29 = !DILocation(line: 3, column: 7, scope: !8)
168 !30 = !DILocation(line: 5, column: 21, scope: !31)
169 !31 = distinct !DILexicalBlock(scope: !18, file: !1, line: 5, column: 3)
170 !32 = !DILocation(line: 5, column: 12, scope: !18)
171 !33 = !DILocation(line: 0, scope: !8)
172 !34 = !DILocation(line: 5, column: 26, scope: !31)
173 !35 = !DILocation(line: 5, column: 3, scope: !18)
174 !36 = distinct !{!36, !35, !37}
175 !37 = !DILocation(line: 6, column: 19, scope: !18)
176 !38 = !DILocation(line: 8, column: 1, scope: !8)