138 lines · plain
1; RUN: opt < %s -passes=gvn -disable-output -pass-remarks=gvn -pass-remarks-missed=gvn \2; RUN: 2>&1 | FileCheck %s3; RUN: opt < %s -passes=gvn -disable-output -pass-remarks-output=%t -S4; RUN: cat %t | FileCheck -check-prefix=YAML %s5 6; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -disable-output -pass-remarks=gvn -pass-remarks-missed=gvn \7; RUN: 2>&1 | FileCheck %s8; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -disable-output -pass-remarks-output=%t -S9; RUN: cat %t | FileCheck -check-prefix=YAML %s10 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 eliminated15 16; YAML: --- !Passed17; YAML-NEXT: Pass: gvn18; YAML-NEXT: Name: LoadElim19; YAML-NEXT: Function: arg20; YAML-NEXT: Args:21; YAML-NEXT: - String: 'load of type '22; YAML-NEXT: - Type: i3223; YAML-NEXT: - String: ' eliminated'24; YAML-NEXT: - String: ' in favor of '25; YAML-NEXT: - InfavorOfValue: i26; YAML-NEXT: ...27; YAML-NEXT: --- !Passed28; YAML-NEXT: Pass: gvn29; YAML-NEXT: Name: LoadElim30; YAML-NEXT: Function: const31; YAML-NEXT: Args:32; YAML-NEXT: - String: 'load of type '33; YAML-NEXT: - Type: i3234; YAML-NEXT: - String: ' eliminated'35; YAML-NEXT: - String: ' in favor of '36; YAML-NEXT: - InfavorOfValue: '4'37; YAML-NEXT: ...38; YAML-NEXT: --- !Passed39; YAML-NEXT: Pass: gvn40; YAML-NEXT: Name: LoadElim41; YAML-NEXT: Function: inst42; YAML-NEXT: Args:43; YAML-NEXT: - String: 'load of type '44; YAML-NEXT: - Type: i3245; YAML-NEXT: - String: ' eliminated'46; YAML-NEXT: - String: ' in favor of '47; YAML-NEXT: - InfavorOfValue: load48; YAML-NEXT: ...49; YAML-NEXT: --- !Missed50; YAML-NEXT: Pass: gvn51; YAML-NEXT: Name: LoadClobbered52; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 3 }53; YAML-NEXT: Function: may_alias54; YAML-NEXT: Args:55; YAML-NEXT: - String: 'load of type '56; YAML-NEXT: - Type: i3257; YAML-NEXT: - String: ' not eliminated'58; YAML-NEXT: - String: ' in favor of '59; YAML-NEXT: - OtherAccess: load60; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 13 }61; YAML-NEXT: - String: ' because it is clobbered by '62; YAML-NEXT: - ClobberedBy: store63; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 2, Column: 10 }64; YAML-NEXT: ...65; YAML-NEXT: --- !Missed66; YAML-NEXT: Pass: gvn67; YAML-NEXT: Name: LoadClobbered68; YAML-NEXT: Function: lifetime_end69; YAML-NEXT: Args:70; YAML-NEXT: - String: 'load of type '71; YAML-NEXT: - Type: i872; YAML-NEXT: - String: ' not eliminated'73; YAML-NEXT: - String: ' in favor of '74; YAML-NEXT: - OtherAccess: store75; YAML-NEXT: - String: ' because it is clobbered by '76; YAML-NEXT: - ClobberedBy: call llvm.lifetime.end.p077; YAML-NEXT: ...78 79define i32 @arg(ptr %p, i32 %i) {80entry:81 store i32 %i, ptr %p82 %load = load i32, ptr %p83 ret i32 %load84}85 86define i32 @const(ptr %p) {87entry:88 store i32 4, ptr %p89 %load = load i32, ptr %p90 ret i32 %load91}92 93define i32 @inst(ptr %p) {94entry:95 %load1 = load i32, ptr %p96 %load = load i32, ptr %p97 %add = add i32 %load1, %load98 ret i32 %add99}100 101define i32 @may_alias(ptr %p, ptr %r) !dbg !7 {102entry:103 %load1 = load i32, ptr %p, !tbaa !13, !dbg !9104 store i32 4, ptr %r, !tbaa !13, !dbg !10105 %load = load i32, ptr %p, !tbaa !13, !dbg !11106 %add = add i32 %load1, %load107 ret i32 %add108}109 110define i8 @lifetime_end(i8 %val) {111 %p = alloca [32 x i8]112 call void @llvm.lifetime.start.p0(ptr %p)113 store i8 %val, ptr %p114 call void @llvm.lifetime.end.p0(ptr %p)115 %1 = load i8, ptr %p116 ret i8 %1117}118 119!llvm.dbg.cu = !{!0}120!llvm.module.flags = !{!3, !4, !5}121!llvm.ident = !{!6}122 123!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)124!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")125!2 = !{}126!3 = !{i32 2, !"Dwarf Version", i32 4}127!4 = !{i32 2, !"Debug Info Version", i32 3}128!5 = !{i32 1, !"PIC Level", i32 2}129!6 = !{!"clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)"}130!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)131!8 = !DISubroutineType(types: !2)132!9 = !DILocation(line: 1, column: 13, scope: !7)133!10 = !DILocation(line: 2, column: 10, scope: !7)134!11 = !DILocation(line: 3, column: 3, scope: !7)135 136!12 = !{ !"tbaa root" }137!13 = !{ !"int", !12 }138