1 ; RUN: opt -S -strip-debug -aa-pipeline=globals-aa,basic-aa -passes='require<globals-aa>,instcombine' < %s | FileCheck %s
2 ; RUN: opt -S -aa-pipeline=globals-aa,basic-aa -passes='require<globals-aa>,instcombine' < %s | FileCheck %s
4 ; Having debug info around shouldn't affect what globals-aa and instcombine do.
8 define void @bar(i8 %p) {
9 call void @llvm.dbg.value(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15
13 declare void @gaz(i8 %p)
16 store i8 42, ptr @g, align 1
18 %_tmp = load i8, ptr @g, align 1
19 call void @gaz(i8 %_tmp)
23 ; Function Attrs: nounwind readnone speculatable
24 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
26 attributes #0 = { nounwind readnone speculatable }
29 !llvm.module.flags = !{!8, !9}
32 !0 = !DIFile(filename: "foo.c", directory: "/tmp")
33 !1 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !2, line: 77, baseType: !3)
34 !2 = !DIFile(filename: "foo.h", directory: "/tmp")
35 !3 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u64_t", file: !0, baseType: !4)
36 !4 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)
37 !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !0, producer: "My Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !6, retainedTypes: !6, globals: !7)
40 !8 = !{i32 2, !"Dwarf Version", i32 4}
41 !9 = !{i32 2, !"Debug Info Version", i32 3}
42 !10 = !{!"My Compiler"}
43 !11 = distinct !DISubprogram(name: "func_5", scope: !0, file: !0, line: 117, type: !12, isLocal: true, isDefinition: true, scopeLine: 118, isOptimized: false, unit: !5, retainedNodes: !6)
44 !12 = !DISubroutineType(types: !13)
46 !14 = !DILocalVariable(name: "p_6", arg: 1, scope: !11, line: 117, type: !1)
47 !15 = !DILocation(line: 117, column: 34, scope: !11)
49 ; instcombine should realize that the load will read 42 from g and pass 42 to
50 ; gaz regardless of the dbg.value in bar.
52 ; CHECK: define void @foo() {
53 ; CHECK-NEXT: store i8 42, ptr @g, align 1
54 ; CHECK-NEXT: call void @bar(i8 1)
55 ; CHECK-NEXT: call void @gaz(i8 42)
56 ; CHECK-NEXT: ret void