137 lines · plain
1; RUN: opt < %s -passes=gvn -o /dev/null -pass-remarks-output=%t -S2; RUN: cat %t | FileCheck %s3 4; CHECK: --- !Missed5; CHECK-NEXT: Pass: gvn6; CHECK-NEXT: Name: LoadClobbered7; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }8; CHECK-NEXT: Function: multipleUsers9; CHECK-NEXT: Args:10; CHECK-NEXT: - String: 'load of type '11; CHECK-NEXT: - Type: i3212; CHECK-NEXT: - String: ' not eliminated'13; CHECK-NEXT: - String: ' in favor of '14; CHECK-NEXT: - OtherAccess: store15; CHECK-NEXT: - String: ' because it is clobbered by '16; CHECK-NEXT: - ClobberedBy: call17; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 1 }18; CHECK-NEXT: ...19; CHECK: --- !Missed20; CHECK-NEXT: Pass: gvn21; CHECK-NEXT: Name: LoadClobbered22; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 4, Column: 4 }23; CHECK-NEXT: Function: multipleUsers24; CHECK-NEXT: Args:25; CHECK-NEXT: - String: 'load of type '26; CHECK-NEXT: - Type: i3227; CHECK-NEXT: - String: ' not eliminated'28; CHECK-NEXT: - String: ' in favor of '29; CHECK-NEXT: - OtherAccess: load30; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }31; CHECK-NEXT: - String: ' because it is clobbered by '32; CHECK-NEXT: - ClobberedBy: call33; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 3 }34; CHECK-NEXT: ...35 36; ModuleID = 'bugpoint-reduced-simplified.bc'37source_filename = "gvn-test.c"38target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"39target triple = "x86_64-unknown-linux-gnu"40 41; Tests that a last clobbering use can be determined even in the presence of42; multiple users, given that one of them lies on a path between every other43; potentially clobbering use and the load.44 45define dso_local void @multipleUsers(ptr %a, i32 %b) local_unnamed_addr #0 {46entry:47 store i32 %b, ptr %a, align 448 tail call void @clobberingFunc() #1, !dbg !1049 %0 = load i32, ptr %a, align 4, !dbg !1150 tail call void @clobberingFunc() #1, !dbg !1251 %1 = load i32, ptr %a, align 4, !dbg !1352 %add2 = add nsw i32 %1, %053 ret void54}55 56; CHECK: --- !Missed57; CHECK-NEXT: Pass: gvn58; CHECK-NEXT: Name: LoadClobbered59; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }60; CHECK-NEXT: Function: multipleUsers261; CHECK-NEXT: Args:62; CHECK-NEXT: - String: 'load of type '63; CHECK-NEXT: - Type: i3264; CHECK-NEXT: - String: ' not eliminated'65; CHECK-NEXT: - String: ' in favor of '66; CHECK-NEXT: - OtherAccess: store67; CHECK-NEXT: - String: ' because it is clobbered by '68; CHECK-NEXT: - ClobberedBy: call69; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 1 }70; CHECK-NEXT: ...71; CHECK: --- !Missed72; CHECK-NEXT: Pass: gvn73; CHECK-NEXT: Name: LoadClobbered74; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 4, Column: 4 }75; CHECK-NEXT: Function: multipleUsers276; CHECK-NEXT: Args:77; CHECK-NEXT: - String: 'load of type '78; CHECK-NEXT: - Type: i3279; CHECK-NEXT: - String: ' not eliminated'80; CHECK-NEXT: - String: ' in favor of '81; CHECK-NEXT: - OtherAccess: load82; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 2 }83; CHECK-NEXT: - String: ' because it is clobbered by '84; CHECK-NEXT: - ClobberedBy: call85; CHECK-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 3 }86; CHECK-NEXT: ...87 88; Ignore uses in other functions89 90define dso_local void @multipleUsers2(i32 %b) local_unnamed_addr #0 {91entry:92 store i32 %b, ptr @g, align 493 tail call void @clobberingFunc() #1, !dbg !1594 %0 = load i32, ptr @g, align 4, !dbg !1695 tail call void @clobberingFunc() #1, !dbg !1796 %1 = load i32, ptr @g, align 4, !dbg !1897 %add3 = add nsw i32 %1, %098 ret void99}100 101declare dso_local void @clobberingFunc() local_unnamed_addr #0102 103@g = external global i32104 105define dso_local void @globalUser(i32 %b) local_unnamed_addr #0 {106entry:107 store i32 %b, ptr @g, align 4108 ret void109}110 111 112attributes #0 = { "use-soft-float"="false" }113attributes #1 = { nounwind }114 115!llvm.dbg.cu = !{!1}116!llvm.module.flags = !{!4, !5, !6}117!llvm.ident = !{!0}118 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")122!3 = !{}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)137