xref: /llvm-project/llvm/test/CodeGen/X86/avoid-sfb-g-no-change.mir (revision 3f07430c383dffad77a120c91df79cbc7d99313c)
1# RUN: llc %s -run-pass x86-avoid-SFB -mtriple=x86_64-unknown-linux-gnu -o - | FileCheck %s -check-prefixes=CHECK,DEBUG
2# RUN: llc %s -run-pass x86-avoid-SFB -mtriple=x86_64-unknown-linux-gnu -o - | FileCheck %s -check-prefixes=CHECK,NODEBUG
3#
4# This was generated from:
5#
6# using alpha = float __attribute__((ext_vector_type(4)));
7#
8# void bravo(alpha * __restrict__ p1, alpha * __restrict__ p2) {
9#   char *p3 = (char *)p1;
10#   *p3 = 0;
11#   alpha t = *p1;
12#   *p2 = t;
13# }
14#
15# Using the command line:
16# clang -g -c 1.cpp -O2 -S -emit-llvm -fno-strict-aliasing --target=x86_64-unknown-unknown -o test.ll
17# llc -stop-before=x86-avoid-SFB test.ll -o before.mir
18
19--- |
20  ; ModuleID = 'test.ll'
21  source_filename = "1.cpp"
22  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23  target triple = "x86_64-unknown-unknown"
24
25  ; Function Attrs: norecurse nounwind uwtable
26  define dso_local void @debug(ptr noalias nocapture %p1, ptr noalias nocapture %p2) local_unnamed_addr #0 !dbg !10 {
27  entry:
28    call void @llvm.dbg.value(metadata ptr %p1, metadata !21, metadata !DIExpression()), !dbg !25
29    call void @llvm.dbg.value(metadata ptr %p2, metadata !22, metadata !DIExpression()), !dbg !25
30    %0 = bitcast ptr %p1 to ptr, !dbg !26
31    call void @llvm.dbg.value(metadata ptr %0, metadata !23, metadata !DIExpression()), !dbg !25
32    store i8 0, ptr %0, align 1, !dbg !27
33    %1 = load <4 x float>, ptr %p1, align 16, !dbg !28
34    call void @llvm.dbg.value(metadata <4 x float> %1, metadata !24, metadata !DIExpression()), !dbg !25
35    store <4 x float> %1, ptr %p2, align 16, !dbg !29
36    ret void, !dbg !30
37  }
38
39  ; Function Attrs: norecurse nounwind uwtable
40  define dso_local void @nodebug(ptr noalias nocapture %p1, ptr noalias nocapture %p2) local_unnamed_addr #0 {
41  entry:
42    %0 = bitcast ptr %p1 to ptr
43    store i8 0, ptr %0, align 1
44    %1 = load <4 x float>, ptr %p1, align 16
45    store <4 x float> %1, ptr %p2, align 16
46    ret void
47  }
48
49  ; Function Attrs: nounwind readnone speculatable
50  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
51
52  ; Function Attrs: nounwind
53  declare void @llvm.stackprotector(ptr, ptr) #2
54
55  attributes #0 = { norecurse nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="all" "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"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
56  attributes #1 = { nounwind readnone speculatable }
57  attributes #2 = { nounwind }
58
59  !llvm.dbg.cu = !{!0}
60  !llvm.module.flags = !{!6, !7, !8}
61  !llvm.ident = !{!9}
62
63  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9afc4764dd24bd2f23c44e51ad33f8e58234a8b6)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
64  !1 = !DIFile(filename: "1.cpp", directory: "C:\5CUsers\5Cgbdawsoc\5CDocuments\5Cllvm\5Cbg40969")
65  !2 = !{}
66  !3 = !{!4}
67  !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
68  !5 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
69  !6 = !{i32 2, !"Dwarf Version", i32 4}
70  !7 = !{i32 2, !"Debug Info Version", i32 3}
71  !8 = !{i32 1, !"wchar_size", i32 4}
72  !9 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9afc4764dd24bd2f23c44e51ad33f8e58234a8b6)"}
73  !10 = distinct !DISubprogram(name: "bravo", linkageName: "_Z5bravoPDv4_fS0_", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20)
74  !11 = !DISubroutineType(types: !12)
75  !12 = !{null, !13, !13}
76  !13 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !14)
77  !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64)
78  !15 = !DIDerivedType(tag: DW_TAG_typedef, name: "alpha", file: !1, line: 2, baseType: !16)
79  !16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 128, flags: DIFlagVector, elements: !18)
80  !17 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
81  !18 = !{!19}
82  !19 = !DISubrange(count: 4)
83  !20 = !{!21, !22, !23, !24}
84  !21 = !DILocalVariable(name: "p1", arg: 1, scope: !10, file: !1, line: 4, type: !13)
85  !22 = !DILocalVariable(name: "p2", arg: 2, scope: !10, file: !1, line: 4, type: !13)
86  !23 = !DILocalVariable(name: "p3", scope: !10, file: !1, line: 5, type: !4)
87  !24 = !DILocalVariable(name: "t", scope: !10, file: !1, line: 7, type: !15)
88  !25 = !DILocation(line: 0, scope: !10)
89  !26 = !DILocation(line: 5, column: 14, scope: !10)
90  !27 = !DILocation(line: 6, column: 7, scope: !10)
91  !28 = !DILocation(line: 7, column: 13, scope: !10)
92  !29 = !DILocation(line: 8, column: 7, scope: !10)
93  !30 = !DILocation(line: 9, column: 1, scope: !10)
94
95...
96---
97name:            debug
98alignment:       16
99exposesReturnsTwice: false
100legalized:       false
101regBankSelected: false
102selected:        false
103failedISel:      false
104tracksRegLiveness: true
105hasWinCFI:       false
106registers:
107  - { id: 0, class: gr64, preferred-register: '' }
108  - { id: 1, class: gr64, preferred-register: '' }
109  - { id: 2, class: vr128, preferred-register: '' }
110liveins:
111  - { reg: '$rdi', virtual-reg: '%0' }
112  - { reg: '$rsi', virtual-reg: '%1' }
113frameInfo:
114  isFrameAddressTaken: false
115  isReturnAddressTaken: false
116  hasStackMap:     false
117  hasPatchPoint:   false
118  stackSize:       0
119  offsetAdjustment: 0
120  maxAlignment:    0
121  adjustsStack:    false
122  hasCalls:        false
123  stackProtector:  ''
124  maxCallFrameSize: 4294967295
125  cvBytesOfCalleeSavedRegisters: 0
126  hasOpaqueSPAdjustment: false
127  hasVAStart:      false
128  hasMustTailInVarArgFunc: false
129  localFrameSize:  0
130  savePoint:       ''
131  restorePoint:    ''
132fixedStack:      []
133stack:           []
134constants:       []
135machineFunctionInfo: {}
136body:             |
137  bb.0.entry:
138    liveins: $rdi, $rsi
139
140    DBG_VALUE $rdi, $noreg, !21, !DIExpression(), debug-location !25
141    DBG_VALUE $rsi, $noreg, !22, !DIExpression(), debug-location !25
142    %1:gr64 = COPY $rsi
143    DBG_VALUE %1, $noreg, !22, !DIExpression(), debug-location !25
144    %0:gr64 = COPY $rdi
145    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
146    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
147    MOV8mi %0, 1, $noreg, 0, $noreg, 0, debug-location !27 :: (store (s8) into %ir.0)
148    %2:vr128 = MOVAPSrm %0, 1, $noreg, 0, $noreg, debug-location !28 :: (load (s128) from %ir.p1)
149    DBG_VALUE %2, $noreg, !24, !DIExpression(), debug-location !25
150    MOVAPSmr %1, 1, $noreg, 0, $noreg, killed %2, debug-location !29 :: (store (s128) into %ir.p2)
151    RET 0, debug-location !30
152
153...
154---
155name:            nodebug
156alignment:       16
157exposesReturnsTwice: false
158legalized:       false
159regBankSelected: false
160selected:        false
161failedISel:      false
162tracksRegLiveness: true
163hasWinCFI:       false
164registers:
165  - { id: 0, class: gr64, preferred-register: '' }
166  - { id: 1, class: gr64, preferred-register: '' }
167  - { id: 2, class: vr128, preferred-register: '' }
168liveins:
169  - { reg: '$rdi', virtual-reg: '%0' }
170  - { reg: '$rsi', virtual-reg: '%1' }
171frameInfo:
172  isFrameAddressTaken: false
173  isReturnAddressTaken: false
174  hasStackMap:     false
175  hasPatchPoint:   false
176  stackSize:       0
177  offsetAdjustment: 0
178  maxAlignment:    0
179  adjustsStack:    false
180  hasCalls:        false
181  stackProtector:  ''
182  maxCallFrameSize: 4294967295
183  cvBytesOfCalleeSavedRegisters: 0
184  hasOpaqueSPAdjustment: false
185  hasVAStart:      false
186  hasMustTailInVarArgFunc: false
187  localFrameSize:  0
188  savePoint:       ''
189  restorePoint:    ''
190fixedStack:      []
191stack:           []
192constants:       []
193machineFunctionInfo: {}
194body:             |
195  bb.0.entry:
196    liveins: $rdi, $rsi
197
198    %1:gr64 = COPY $rsi
199    %0:gr64 = COPY $rdi
200    MOV8mi %0, 1, $noreg, 0, $noreg, 0 :: (store (s8) into %ir.0)
201    %2:vr128 = MOVAPSrm %0, 1, $noreg, 0, $noreg :: (load (s128) from %ir.p1)
202    MOVAPSmr %1, 1, $noreg, 0, $noreg, killed %2 :: (store (s128) into %ir.p2)
203    RET 0
204
205    ; DEBUG: name: debug
206    ; NODEBUG: name: nodebug
207    ; CHECK: %1:gr64 = COPY
208    ; CHECK: %0:gr64 = COPY
209    ; CHECK: MOV8mi
210    ; CHECK: %3:gr8 = MOV8rm
211    ; CHECK: MOV8mr
212    ; CHECK: %4:gr64 = MOV64rm
213    ; CHECK: MOV64mr
214    ; CHECK: %5:gr32 = MOV32rm
215    ; CHECK: MOV32mr
216    ; CHECK: %6:gr16 = MOV16rm
217    ; CHECK: MOV16mr
218    ; CHECK: %7:gr8 = MOV8rm
219    ; CHECK: MOV8mr
220    ; CHECK: RET 0
221    ; DEBUG: name: nodebug
222...
223