1; RUN: opt < %s -gvn -o /dev/null -S -pass-remarks=gvn -pass-remarks-missed=gvn \ 2; RUN: 2>&1 | FileCheck %s 3; RUN: opt < %s -gvn -o /dev/null -pass-remarks-output=%t -S 4; RUN: cat %t | FileCheck -check-prefix=YAML %s 5 6; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -o /dev/null -S -pass-remarks=gvn -pass-remarks-missed=gvn \ 7; RUN: 2>&1 | FileCheck %s 8; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -o /dev/null -pass-remarks-output=%t -S 9; RUN: cat %t | FileCheck -check-prefix=YAML %s 10 11; CHECK: remark: <unknown>:0:0: load of type i32 eliminated{{$}} 12; CHECK-NEXT: remark: <unknown>:0:0: load of type i32 eliminated{{$}} 13; CHECK-NEXT: remark: <unknown>:0:0: load of type i32 eliminated{{$}} 14; CHECK-NEXT: remark: /tmp/s.c:3:3: load of type i32 not eliminated 15 16; YAML: --- !Passed 17; YAML-NEXT: Pass: gvn 18; YAML-NEXT: Name: LoadElim 19; YAML-NEXT: Function: arg 20; YAML-NEXT: Args: 21; YAML-NEXT: - String: 'load of type ' 22; YAML-NEXT: - Type: i32 23; YAML-NEXT: - String: ' eliminated' 24; YAML-NEXT: - String: ' in favor of ' 25; YAML-NEXT: - InfavorOfValue: i 26; YAML-NEXT: ... 27; YAML-NEXT: --- !Passed 28; YAML-NEXT: Pass: gvn 29; YAML-NEXT: Name: LoadElim 30; YAML-NEXT: Function: const 31; YAML-NEXT: Args: 32; YAML-NEXT: - String: 'load of type ' 33; YAML-NEXT: - Type: i32 34; YAML-NEXT: - String: ' eliminated' 35; YAML-NEXT: - String: ' in favor of ' 36; YAML-NEXT: - InfavorOfValue: '4' 37; YAML-NEXT: ... 38; YAML-NEXT: --- !Passed 39; YAML-NEXT: Pass: gvn 40; YAML-NEXT: Name: LoadElim 41; YAML-NEXT: Function: inst 42; YAML-NEXT: Args: 43; YAML-NEXT: - String: 'load of type ' 44; YAML-NEXT: - Type: i32 45; YAML-NEXT: - String: ' eliminated' 46; YAML-NEXT: - String: ' in favor of ' 47; YAML-NEXT: - InfavorOfValue: load 48; YAML-NEXT: ... 49; YAML-NEXT: --- !Missed 50; YAML-NEXT: Pass: gvn 51; YAML-NEXT: Name: LoadClobbered 52; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 3, Column: 3 } 53; YAML-NEXT: Function: may_alias 54; YAML-NEXT: Args: 55; YAML-NEXT: - String: 'load of type ' 56; YAML-NEXT: - Type: i32 57; YAML-NEXT: - String: ' not eliminated' 58; YAML-NEXT: - String: ' in favor of ' 59; YAML-NEXT: - OtherAccess: load 60; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 1, Column: 13 } 61; YAML-NEXT: - String: ' because it is clobbered by ' 62; YAML-NEXT: - ClobberedBy: store 63; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 2, Column: 10 } 64; YAML-NEXT: ... 65 66define i32 @arg(i32* %p, i32 %i) { 67entry: 68 store i32 %i, i32* %p 69 %load = load i32, i32* %p 70 ret i32 %load 71} 72 73define i32 @const(i32* %p) { 74entry: 75 store i32 4, i32* %p 76 %load = load i32, i32* %p 77 ret i32 %load 78} 79 80define i32 @inst(i32* %p) { 81entry: 82 %load1 = load i32, i32* %p 83 %load = load i32, i32* %p 84 %add = add i32 %load1, %load 85 ret i32 %add 86} 87 88define i32 @may_alias(i32* %p, i32* %r) !dbg !7 { 89entry: 90 %load1 = load i32, i32* %p, !tbaa !13, !dbg !9 91 store i32 4, i32* %r, !tbaa !13, !dbg !10 92 %load = load i32, i32* %p, !tbaa !13, !dbg !11 93 %add = add i32 %load1, %load 94 ret i32 %add 95} 96!llvm.dbg.cu = !{!0} 97!llvm.module.flags = !{!3, !4, !5} 98!llvm.ident = !{!6} 99 100!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) 101!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp") 102!2 = !{} 103!3 = !{i32 2, !"Dwarf Version", i32 4} 104!4 = !{i32 2, !"Debug Info Version", i32 3} 105!5 = !{i32 1, !"PIC Level", i32 2} 106!6 = !{!"clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)"} 107!7 = distinct !DISubprogram(name: "may_alias", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !2) 108!8 = !DISubroutineType(types: !2) 109!9 = !DILocation(line: 1, column: 13, scope: !7) 110!10 = !DILocation(line: 2, column: 10, scope: !7) 111!11 = !DILocation(line: 3, column: 3, scope: !7) 112 113!12 = !{ !"tbaa root" } 114!13 = !{ !"int", !12 } 115