1 ; RUN: opt -mem2reg -instcombine %s -o - -S | FileCheck %s
3 ; Test that a dbg.declare describing am alloca with volatile
4 ; load/stores is not lowered into a dbg.value, since the alloca won't
9 ; unsigned long long g();
10 ; void h(unsigned long long);
12 ; volatile unsigned long long v = g();
19 ; CHECK-NOT: call void @llvm.dbg.value
20 ; CHECK: call void @llvm.dbg.declare
21 ; CHECK-NOT: call void @llvm.dbg.value
23 source_filename = "volatile.c"
25 ; Function Attrs: nounwind optsize ssp uwtable
26 define void @f() local_unnamed_addr #0 !dbg !8 {
27 %1 = alloca i64, align 8
28 %2 = bitcast i64* %1 to i8*, !dbg !15
29 call void @llvm.lifetime.start.p0i8(i64 8, i8* %2), !dbg !15
30 call void @llvm.dbg.declare(metadata i64* %1, metadata !12, metadata !DIExpression()), !dbg !15
31 %3 = call i64 (...) @g() #4, !dbg !15
32 store volatile i64 %3, i64* %1, align 8, !dbg !15
33 %4 = load volatile i64, i64* %1, align 8, !dbg !15
34 %5 = icmp eq i64 %4, 0, !dbg !15
35 br i1 %5, label %6, label %8, !dbg !15
37 ; <label>:6: ; preds = %0
38 %7 = call i64 (...) @g() #4, !dbg !15
41 ; <label>:8: ; preds = %6, %0
42 %9 = load volatile i64, i64* %1, align 8, !dbg !15
43 call void @h(i64 %9) #4, !dbg !15
44 call void @llvm.lifetime.end.p0i8(i64 8, i8* %2), !dbg !15
48 ; Function Attrs: argmemonly nounwind
49 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
51 ; Function Attrs: nounwind readnone speculatable
52 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
54 ; Function Attrs: optsize
55 declare i64 @g(...) local_unnamed_addr #3
57 ; Function Attrs: optsize
58 declare void @h(i64) local_unnamed_addr #3
60 ; Function Attrs: argmemonly nounwind
61 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
63 attributes #0 = { nounwind optsize ssp uwtable }
64 attributes #1 = { argmemonly nounwind }
65 attributes #2 = { nounwind readnone speculatable }
66 attributes #3 = { optsize }
67 attributes #4 = { optsize }
70 !llvm.module.flags = !{!3, !4}
72 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
73 !1 = !DIFile(filename: "volatile.c", directory: "/")
74 !3 = !{i32 2, !"Dwarf Version", i32 4}
75 !4 = !{i32 2, !"Debug Info Version", i32 3}
76 !8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, retainedNodes: !11)
77 !9 = !DISubroutineType(types: !10)
80 !12 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !13)
81 !13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !14)
82 !14 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
83 !15 = !DILocation(line: 4, column: 3, scope: !8)