1# RUN: llc %s -run-pass x86-avoid-SFB -mtriple=x86_64-unknown-linux-gnu -o - | FileCheck %s
2#
3# This was generated from:
4#
5# using alpha = float __attribute__((ext_vector_type(4)));
6#
7# void bravo(alpha * __restrict__ p1, alpha * __restrict__ p2) {
8#   char *p3 = (char *)p1;
9#   *p3 = 0;
10#   alpha t = *p1;
11#   *p2 = t;
12# }
13#
14# Using the command line:
15# clang -g -c 1.cpp -O2 -S -emit-llvm -fno-strict-aliasing --target=x86_64-unknown-unknown -o test.ll
16# llc -stop-before=x86-avoid-SFB test.ll -o before.mir
17#
18# The IR has been modified to include a number of debug/meta instructions between the initial store and load.
19# If the code treats debug/meta instructions as normal instructions, the separation between the store and load
20# will be too great to enable the optimization.
21
22--- |
23  ; ModuleID = 'test.ll'
24  source_filename = "1.cpp"
25  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26  target triple = "x86_64-unknown-unknown"
27
28  ; Function Attrs: norecurse nounwind uwtable
29  define dso_local void @debug(<4 x float>* noalias nocapture %p1, <4 x float>* noalias nocapture %p2) local_unnamed_addr #0 !dbg !10 {
30  entry:
31    call void @llvm.dbg.value(metadata <4 x float>* %p1, metadata !21, metadata !DIExpression()), !dbg !25
32    call void @llvm.dbg.value(metadata <4 x float>* %p2, metadata !22, metadata !DIExpression()), !dbg !25
33    %0 = bitcast <4 x float>* %p1 to i8*, !dbg !26
34    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
35    store i8 0, i8* %0, align 1, !dbg !27
36    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
37    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
38    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
39    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
40    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
41    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
42    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
43    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
44    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
45    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
46    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
47    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
48    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
49    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
50    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
51    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
52    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
53    call void @llvm.dbg.value(metadata i8* %0, metadata !23, metadata !DIExpression()), !dbg !25
54    %1 = load <4 x float>, <4 x float>* %p1, align 16, !dbg !28
55    call void @llvm.dbg.value(metadata <4 x float> %1, metadata !24, metadata !DIExpression()), !dbg !25
56    store <4 x float> %1, <4 x float>* %p2, align 16, !dbg !29
57    ret void, !dbg !30
58  }
59
60  ; Function Attrs: nounwind readnone speculatable
61  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
62
63  ; Function Attrs: nounwind
64  declare void @llvm.stackprotector(i8*, i8**) #2
65
66  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" }
67  attributes #1 = { nounwind readnone speculatable }
68  attributes #2 = { nounwind }
69
70  !llvm.dbg.cu = !{!0}
71  !llvm.module.flags = !{!6, !7, !8}
72  !llvm.ident = !{!9}
73
74  !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)
75  !1 = !DIFile(filename: "1.cpp", directory: "C:\5CUsers\5Cgbdawsoc\5CDocuments\5Cllvm\5Cbg40969")
76  !2 = !{}
77  !3 = !{!4}
78  !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
79  !5 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
80  !6 = !{i32 2, !"Dwarf Version", i32 4}
81  !7 = !{i32 2, !"Debug Info Version", i32 3}
82  !8 = !{i32 1, !"wchar_size", i32 4}
83  !9 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 9afc4764dd24bd2f23c44e51ad33f8e58234a8b6)"}
84  !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)
85  !11 = !DISubroutineType(types: !12)
86  !12 = !{null, !13, !13}
87  !13 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !14)
88  !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64)
89  !15 = !DIDerivedType(tag: DW_TAG_typedef, name: "alpha", file: !1, line: 2, baseType: !16)
90  !16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 128, flags: DIFlagVector, elements: !18)
91  !17 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
92  !18 = !{!19}
93  !19 = !DISubrange(count: 4)
94  !20 = !{!21, !22, !23, !24}
95  !21 = !DILocalVariable(name: "p1", arg: 1, scope: !10, file: !1, line: 4, type: !13)
96  !22 = !DILocalVariable(name: "p2", arg: 2, scope: !10, file: !1, line: 4, type: !13)
97  !23 = !DILocalVariable(name: "p3", scope: !10, file: !1, line: 5, type: !4)
98  !24 = !DILocalVariable(name: "t", scope: !10, file: !1, line: 7, type: !15)
99  !25 = !DILocation(line: 0, scope: !10)
100  !26 = !DILocation(line: 5, column: 14, scope: !10)
101  !27 = !DILocation(line: 6, column: 7, scope: !10)
102  !28 = !DILocation(line: 7, column: 13, scope: !10)
103  !29 = !DILocation(line: 8, column: 7, scope: !10)
104  !30 = !DILocation(line: 9, column: 1, scope: !10)
105
106...
107---
108name:            debug
109alignment:       16
110exposesReturnsTwice: false
111legalized:       false
112regBankSelected: false
113selected:        false
114failedISel:      false
115tracksRegLiveness: true
116hasWinCFI:       false
117registers:
118  - { id: 0, class: gr64, preferred-register: '' }
119  - { id: 1, class: gr64, preferred-register: '' }
120  - { id: 2, class: vr128, preferred-register: '' }
121liveins:
122  - { reg: '$rdi', virtual-reg: '%0' }
123  - { reg: '$rsi', virtual-reg: '%1' }
124frameInfo:
125  isFrameAddressTaken: false
126  isReturnAddressTaken: false
127  hasStackMap:     false
128  hasPatchPoint:   false
129  stackSize:       0
130  offsetAdjustment: 0
131  maxAlignment:    0
132  adjustsStack:    false
133  hasCalls:        false
134  stackProtector:  ''
135  maxCallFrameSize: 4294967295
136  cvBytesOfCalleeSavedRegisters: 0
137  hasOpaqueSPAdjustment: false
138  hasVAStart:      false
139  hasMustTailInVarArgFunc: false
140  localFrameSize:  0
141  savePoint:       ''
142  restorePoint:    ''
143fixedStack:      []
144stack:           []
145constants:       []
146machineFunctionInfo: {}
147body:             |
148  bb.0.entry:
149    liveins: $rdi, $rsi
150
151    DBG_VALUE $rdi, $noreg, !21, !DIExpression(), debug-location !25
152    DBG_VALUE $rsi, $noreg, !22, !DIExpression(), debug-location !25
153    %1:gr64 = COPY $rsi
154    DBG_VALUE %1, $noreg, !22, !DIExpression(), debug-location !25
155    %0:gr64 = COPY $rdi
156    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
157    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
158    MOV8mi %0, 1, $noreg, 0, $noreg, 0, debug-location !27 :: (store (s8) into %ir.0)
159    CFI_INSTRUCTION offset $r13, -123
160    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
161    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
162    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
163    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
164    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
165    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
166    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
167    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
168    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
169    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
170    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
171    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
172    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
173    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
174    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
175    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
176    DBG_VALUE %0, $noreg, !21, !DIExpression(), debug-location !25
177    DBG_VALUE %0, $noreg, !23, !DIExpression(), debug-location !25
178    %2:vr128 = MOVAPSrm %0, 1, $noreg, 0, $noreg, debug-location !28 :: (load (s128) from %ir.p1)
179    DBG_VALUE %2, $noreg, !24, !DIExpression(), debug-location !25
180    MOVAPSmr %1, 1, $noreg, 0, $noreg, killed %2, debug-location !29 :: (store (s128) into %ir.p2)
181    RET 0, debug-location !30
182
183  ; CHECK-LABEL: name: debug
184  ; CHECK: %1:gr64 = COPY
185  ; CHECK: %0:gr64 = COPY
186  ; CHECK: MOV8mi
187  ; CHECK: %3:gr8 = MOV8rm
188  ; CHECK: MOV8mr
189  ; CHECK: %4:gr64 = MOV64rm
190  ; CHECK: MOV64mr
191  ; CHECK: %5:gr32 = MOV32rm
192  ; CHECK: MOV32mr
193  ; CHECK: %6:gr16 = MOV16rm
194  ; CHECK: MOV16mr
195  ; CHECK: %7:gr8 = MOV8rm
196  ; CHECK: MOV8mr
197  ; CHECK: RET 0
198...
199