1 ; RUN: opt < %s -gvn -o /dev/null -pass-remarks-output=%t -S
2 ; RUN: cat %t | FileCheck %s
5 ; CHECK-NEXT: Pass: gvn
6 ; CHECK-NEXT: Name: LoadClobbered
7 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }
8 ; CHECK-NEXT: Function: multipleUsers
10 ; CHECK-NEXT: - String: 'load of type '
11 ; CHECK-NEXT: - Type: i32
12 ; CHECK-NEXT: - String: ' not eliminated'
13 ; CHECK-NEXT: - String: ' in favor of '
14 ; CHECK-NEXT: - OtherAccess: store
15 ; CHECK-NEXT: - String: ' because it is clobbered by '
16 ; CHECK-NEXT: - ClobberedBy: call
17 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 1 }
20 ; CHECK-NEXT: Pass: gvn
21 ; CHECK-NEXT: Name: LoadClobbered
22 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 4, Column: 4 }
23 ; CHECK-NEXT: Function: multipleUsers
25 ; CHECK-NEXT: - String: 'load of type '
26 ; CHECK-NEXT: - Type: i32
27 ; CHECK-NEXT: - String: ' not eliminated'
28 ; CHECK-NEXT: - String: ' in favor of '
29 ; CHECK-NEXT: - OtherAccess: load
30 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }
31 ; CHECK-NEXT: - String: ' because it is clobbered by '
32 ; CHECK-NEXT: - ClobberedBy: call
33 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 3 }
36 ; ModuleID = 'bugpoint-reduced-simplified.bc'
37 source_filename = "gvn-test.c"
38 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-unknown-linux-gnu"
41 ; Tests that a last clobbering use can be determined even in the presence of
42 ; multiple users, given that one of them lies on a path between every other
43 ; potentially clobbering use and the load.
45 define dso_local void @multipleUsers(i32* %a, i32 %b) local_unnamed_addr #0 {
47 store i32 %b, i32* %a, align 4
48 tail call void @clobberingFunc() #1, !dbg !10
49 %0 = load i32, i32* %a, align 4, !dbg !11
50 tail call void @clobberingFunc() #1, !dbg !12
51 %1 = load i32, i32* %a, align 4, !dbg !13
52 %add2 = add nsw i32 %1, %0
57 ; CHECK-NEXT: Pass: gvn
58 ; CHECK-NEXT: Name: LoadClobbered
59 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }
60 ; CHECK-NEXT: Function: multipleUsers2
62 ; CHECK-NEXT: - String: 'load of type '
63 ; CHECK-NEXT: - Type: i32
64 ; CHECK-NEXT: - String: ' not eliminated'
65 ; CHECK-NEXT: - String: ' in favor of '
66 ; CHECK-NEXT: - OtherAccess: store
67 ; CHECK-NEXT: - String: ' because it is clobbered by '
68 ; CHECK-NEXT: - ClobberedBy: call
69 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 1 }
72 ; CHECK-NEXT: Pass: gvn
73 ; CHECK-NEXT: Name: LoadClobbered
74 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 4, Column: 4 }
75 ; CHECK-NEXT: Function: multipleUsers2
77 ; CHECK-NEXT: - String: 'load of type '
78 ; CHECK-NEXT: - Type: i32
79 ; CHECK-NEXT: - String: ' not eliminated'
80 ; CHECK-NEXT: - String: ' in favor of '
81 ; CHECK-NEXT: - OtherAccess: load
82 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }
83 ; CHECK-NEXT: - String: ' because it is clobbered by '
84 ; CHECK-NEXT: - ClobberedBy: call
85 ; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 3 }
88 ; Ignore uses in other functions
90 define dso_local void @multipleUsers2(i32 %b) local_unnamed_addr #0 {
92 store i32 %b, i32* @g, align 4
93 tail call void @clobberingFunc() #1, !dbg !15
94 %0 = load i32, i32* @g, align 4, !dbg !16
95 tail call void @clobberingFunc() #1, !dbg !17
96 %1 = load i32, i32* @g, align 4, !dbg !18
97 %add3 = add nsw i32 %1, %0
101 declare dso_local void @clobberingFunc() local_unnamed_addr #0
103 @g = external global i32
105 define dso_local void @globalUser(i32 %b) local_unnamed_addr #0 {
107 store i32 %b, i32* @g, align 4
112 attributes #0 = { "use-soft-float"="false" }
113 attributes #1 = { nounwind }
116 !llvm.module.flags = !{!4, !5, !6}
119 !0 = !{!"clang version 10.0.0 (git@github.com:llvm/llvm-project.git a2f6ae9abffcba260c22bb235879f0576bf3b783)"}
120 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !3)
121 !2 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
123 !4 = !{i32 2, !"Dwarf Version", i32 4}
124 !5 = !{i32 2, !"Debug Info Version", i32 3}
125 !6 = !{i32 1, !"PIC Level", i32 2}
126 !8 = distinct !DISubprogram(name: "multipleUsers", scope: !2, file: !2, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !1, retainedNodes: !3)
127 !9 = !DISubroutineType(types: !3)
128 !10 = !DILocation(line: 1, column: 1, scope: !8)
129 !11 = !DILocation(line: 2, column: 2, scope: !8)
130 !12 = !DILocation(line: 3, column: 3, scope: !8)
131 !13 = !DILocation(line: 4, column: 4, scope: !8)
132 !14 = distinct !DISubprogram(name: "multipleUsers2", scope: !2, file: !2, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !1, retainedNodes: !3)
133 !15 = !DILocation(line: 1, column: 1, scope: !14)
134 !16 = !DILocation(line: 2, column: 2, scope: !14)
135 !17 = !DILocation(line: 3, column: 3, scope: !14)
136 !18 = !DILocation(line: 4, column: 4, scope: !14)