• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -strip-debug -globals-aa -instcombine < %s | FileCheck %s
2; RUN: opt -S -globals-aa -instcombine < %s | FileCheck %s
3
4; Having debug info around shouldn't affect what globals-aa and instcombine do.
5
6@g = global i8 0
7
8define void @bar(i8 %p) {
9   call void @llvm.dbg.value(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15
10  ret void
11}
12
13declare void @gaz(i8 %p)
14
15define void @foo() {
16  store i8 42, i8* @g, align 1
17  call void @bar(i8 1)
18  %_tmp = load i8, i8* @g, align 1
19  call void @gaz(i8 %_tmp)
20  ret void
21}
22
23; Function Attrs: nounwind readnone speculatable
24declare void @llvm.dbg.value(metadata, metadata, metadata) #0
25
26attributes #0 = { nounwind readnone speculatable }
27
28!llvm.dbg.cu = !{!5}
29!llvm.module.flags = !{!8, !9}
30!llvm.ident = !{!10}
31
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)
38!6 = !{}
39!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)
45!13 = !{}
46!14 = !DILocalVariable(name: "p_6", arg: 1, scope: !11, line: 117, type: !1)
47!15 = !DILocation(line: 117, column: 34, scope: !11)
48
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.
51
52; CHECK: define void @foo() {
53; CHECK-NEXT:  store i8 42, i8* @g, align 1
54; CHECK-NEXT:  call void @bar(i8 1)
55; CHECK-NEXT:  call void @gaz(i8 42)
56; CHECK-NEXT:  ret void
57
58