--- /dev/null
+; RUN: llc -march=mips -mcpu=mips32r2 -O1 -filetype=obj <%s | \
+; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F0
+; RUN: llc -march=mips -mcpu=mips32r2 -O1 -filetype=obj <%s | \
+; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F1
+
+; void foo(int *);
+;
+; int f0(int a, int b, int c, int d, int e) {
+; int x = a + b + c + d + e;
+; foo(&x);
+; return x;
+; }
+;
+; int f1(int a, int b, int c, int d, int e) {
+; int x __attribute__((aligned(16))) = a + b + c + d + e;
+; foo(&x);
+; return x;
+; }
+
+declare void @llvm.lifetime.start(i64, i8* nocapture)
+declare void @llvm.lifetime.end(i64, i8* nocapture)
+
+declare void @foo(i32*)
+
+; F0: DW_AT_location [DW_FORM_sec_offset] (0x00000014)
+; F0: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x")
+;
+; x -> DW_OP_reg1(51)
+; F0: 0x00000014: Beginning address offset: 0x0000000000000028
+; F0: Ending address offset: 0x0000000000000030
+; F0: Location description: 51
+
+define i32 @f0(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e) !dbg !4 {
+entry:
+ %x = alloca i32, align 4
+ tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !9, metadata !26), !dbg !27
+ tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !10, metadata !26), !dbg !28
+ tail call void @llvm.dbg.value(metadata i32 %c, i64 0, metadata !11, metadata !26), !dbg !29
+ tail call void @llvm.dbg.value(metadata i32 %d, i64 0, metadata !12, metadata !26), !dbg !30
+ tail call void @llvm.dbg.value(metadata i32 %e, i64 0, metadata !13, metadata !26), !dbg !31
+ %0 = bitcast i32* %x to i8*, !dbg !32
+ call void @llvm.lifetime.start(i64 4, i8* %0) #4, !dbg !32
+ %add = add nsw i32 %b, %a, !dbg !33
+ %add1 = add nsw i32 %add, %c, !dbg !34
+ %add2 = add nsw i32 %add1, %d, !dbg !35
+ %add3 = add nsw i32 %add2, %e, !dbg !36
+ tail call void @llvm.dbg.value(metadata i32 %add3, i64 0, metadata !14, metadata !26), !dbg !37
+ store i32 %add3, i32* %x, align 4, !dbg !37, !tbaa !38
+ tail call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !14, metadata !26), !dbg !37
+ call void @foo(i32* nonnull %x) #4, !dbg !42
+ call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !14, metadata !26), !dbg !37
+ %1 = load i32, i32* %x, align 4, !dbg !43, !tbaa !38
+ call void @llvm.lifetime.end(i64 4, i8* %0) #4, !dbg !44
+ ret i32 %1, !dbg !45
+}
+
+
+; F1: DW_AT_location [DW_FORM_sec_offset] (0x00000033)
+; F1: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x")
+
+; x -> DW_OP_reg1(51)
+; F1: 0x00000033: Beginning address offset: 0x0000000000000080
+; F1: Ending address offset: 0x0000000000000088
+; F1: Location description: 51
+
+define i32 @f1(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e) !dbg !15 {
+entry:
+ %x = alloca i32, align 16
+ tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !17, metadata !26), !dbg !46
+ tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !18, metadata !26), !dbg !47
+ tail call void @llvm.dbg.value(metadata i32 %c, i64 0, metadata !19, metadata !26), !dbg !48
+ tail call void @llvm.dbg.value(metadata i32 %d, i64 0, metadata !20, metadata !26), !dbg !49
+ tail call void @llvm.dbg.value(metadata i32 %e, i64 0, metadata !21, metadata !26), !dbg !50
+ %0 = bitcast i32* %x to i8*, !dbg !51
+ call void @llvm.lifetime.start(i64 4, i8* %0) #4, !dbg !51
+ %add = add nsw i32 %b, %a, !dbg !52
+ %add1 = add nsw i32 %add, %c, !dbg !53
+ %add2 = add nsw i32 %add1, %d, !dbg !54
+ %add3 = add nsw i32 %add2, %e, !dbg !55
+ tail call void @llvm.dbg.value(metadata i32 %add3, i64 0, metadata !22, metadata !26), !dbg !56
+ store i32 %add3, i32* %x, align 16, !dbg !56, !tbaa !38
+ tail call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !22, metadata !26), !dbg !56
+ call void @foo(i32* nonnull %x) #4, !dbg !57
+ call void @llvm.dbg.value(metadata i32* %x, i64 0, metadata !22, metadata !26), !dbg !56
+ %1 = load i32, i32* %x, align 16, !dbg !58, !tbaa !38
+ call void @llvm.lifetime.end(i64 4, i8* %0) #4, !dbg !59
+ ret i32 %1, !dbg !60
+}
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!23, !24}
+!llvm.ident = !{!25}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
+!1 = !DIFile(filename: "test.c", directory: "/home/vk/repos/tmp/dwarf")
+!2 = !{}
+!3 = !{!4, !15}
+!4 = distinct !DISubprogram(name: "f0", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, variables: !8)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7, !7, !7, !7, !7, !7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!8 = !{!9, !10, !11, !12, !13, !14}
+!9 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 4, type: !7)
+!10 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 4, type: !7)
+!11 = !DILocalVariable(name: "c", arg: 3, scope: !4, file: !1, line: 4, type: !7)
+!12 = !DILocalVariable(name: "d", arg: 4, scope: !4, file: !1, line: 4, type: !7)
+!13 = !DILocalVariable(name: "e", arg: 5, scope: !4, file: !1, line: 4, type: !7)
+!14 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 5, type: !7)
+!15 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 11, type: !5, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: true, variables: !16)
+!16 = !{!17, !18, !19, !20, !21, !22}
+!17 = !DILocalVariable(name: "a", arg: 1, scope: !15, file: !1, line: 11, type: !7)
+!18 = !DILocalVariable(name: "b", arg: 2, scope: !15, file: !1, line: 11, type: !7)
+!19 = !DILocalVariable(name: "c", arg: 3, scope: !15, file: !1, line: 11, type: !7)
+!20 = !DILocalVariable(name: "d", arg: 4, scope: !15, file: !1, line: 11, type: !7)
+!21 = !DILocalVariable(name: "e", arg: 5, scope: !15, file: !1, line: 11, type: !7)
+!22 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 12, type: !7)
+!23 = !{i32 2, !"Dwarf Version", i32 4}
+!24 = !{i32 2, !"Debug Info Version", i32 3}
+!25 = !{!"clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)"}
+!26 = !DIExpression()
+!27 = !DILocation(line: 4, column: 12, scope: !4)
+!28 = !DILocation(line: 4, column: 19, scope: !4)
+!29 = !DILocation(line: 4, column: 26, scope: !4)
+!30 = !DILocation(line: 4, column: 33, scope: !4)
+!31 = !DILocation(line: 4, column: 40, scope: !4)
+!32 = !DILocation(line: 5, column: 3, scope: !4)
+!33 = !DILocation(line: 5, column: 13, scope: !4)
+!34 = !DILocation(line: 5, column: 17, scope: !4)
+!35 = !DILocation(line: 5, column: 21, scope: !4)
+!36 = !DILocation(line: 5, column: 25, scope: !4)
+!37 = !DILocation(line: 5, column: 7, scope: !4)
+!38 = !{!39, !39, i64 0}
+!39 = !{!"int", !40, i64 0}
+!40 = !{!"omnipotent char", !41, i64 0}
+!41 = !{!"Simple C/C++ TBAA"}
+!42 = !DILocation(line: 6, column: 3, scope: !4)
+!43 = !DILocation(line: 7, column: 10, scope: !4)
+!44 = !DILocation(line: 8, column: 1, scope: !4)
+!45 = !DILocation(line: 7, column: 3, scope: !4)
+!46 = !DILocation(line: 11, column: 12, scope: !15)
+!47 = !DILocation(line: 11, column: 19, scope: !15)
+!48 = !DILocation(line: 11, column: 26, scope: !15)
+!49 = !DILocation(line: 11, column: 33, scope: !15)
+!50 = !DILocation(line: 11, column: 40, scope: !15)
+!51 = !DILocation(line: 12, column: 3, scope: !15)
+!52 = !DILocation(line: 12, column: 42, scope: !15)
+!53 = !DILocation(line: 12, column: 46, scope: !15)
+!54 = !DILocation(line: 12, column: 50, scope: !15)
+!55 = !DILocation(line: 12, column: 54, scope: !15)
+!56 = !DILocation(line: 12, column: 7, scope: !15)
+!57 = !DILocation(line: 13, column: 3, scope: !15)
+!58 = !DILocation(line: 14, column: 10, scope: !15)
+!59 = !DILocation(line: 15, column: 1, scope: !15)
+!60 = !DILocation(line: 14, column: 3, scope: !15)
--- /dev/null
+; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj <%s | \
+; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F2
+; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj <%s | \
+; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F3
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+declare void @foo(i32*)
+
+; void foo(int *);
+;
+; int f2(int a, int b) {
+; int c __attribute__((aligned(16))) = a + b;
+; foo(&c);
+; return c;
+; }
+;
+; int *f3(int a, int b) {
+; int c __attribute__((aligned(16))) = a + b;
+; int *w = alloca(c);
+; foo(&c);
+; return w;
+; }
+
+; c -> DW_OP_breg29(r29): 16
+; F2: DW_AT_location [DW_FORM_exprloc] (<0x2> 8d 10 )
+; F2: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c")
+
+; Function Attrs: nounwind
+define i32 @f2(i32 signext %a, i32 signext %b) !dbg !4 {
+entry:
+ %a.addr = alloca i32, align 4
+ %b.addr = alloca i32, align 4
+ %c = alloca i32, align 16
+ store i32 %a, i32* %a.addr, align 4
+ call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !15, metadata !16), !dbg !17
+ store i32 %b, i32* %b.addr, align 4
+ call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !18, metadata !16), !dbg !19
+ call void @llvm.dbg.declare(metadata i32* %c, metadata !20, metadata !16), !dbg !21
+ %0 = load i32, i32* %a.addr, align 4, !dbg !22
+ %1 = load i32, i32* %b.addr, align 4, !dbg !23
+ %add = add nsw i32 %0, %1, !dbg !24
+ store i32 %add, i32* %c, align 16, !dbg !21
+ call void @foo(i32* %c), !dbg !25
+ %2 = load i32, i32* %c, align 16, !dbg !26
+ ret i32 %2, !dbg !27
+}
+
+; c -> DW_OP_breg23(r23): 16
+; F3: DW_AT_location [DW_FORM_exprloc] (<0x2> 87 10 )
+; F3: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c")
+
+define i32* @f3(i32 signext %a, i32 signext %b) !dbg !8 {
+entry:
+ %a.addr = alloca i32, align 4
+ %b.addr = alloca i32, align 4
+ %c = alloca i32, align 16
+ %w = alloca i32*, align 4
+ store i32 %a, i32* %a.addr, align 4
+ call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !28, metadata !16), !dbg !29
+ store i32 %b, i32* %b.addr, align 4
+ call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !30, metadata !16), !dbg !31
+ call void @llvm.dbg.declare(metadata i32* %c, metadata !32, metadata !16), !dbg !33
+ %0 = load i32, i32* %a.addr, align 4, !dbg !34
+ %1 = load i32, i32* %b.addr, align 4, !dbg !35
+ %add = add nsw i32 %0, %1, !dbg !36
+ store i32 %add, i32* %c, align 16, !dbg !33
+ call void @llvm.dbg.declare(metadata i32** %w, metadata !37, metadata !16), !dbg !38
+ %2 = load i32, i32* %c, align 16, !dbg !39
+ %3 = alloca i8, i32 %2, !dbg !40
+ %4 = bitcast i8* %3 to i32*, !dbg !40
+ store i32* %4, i32** %w, align 4, !dbg !38
+ call void @foo(i32* %c), !dbg !41
+ %5 = load i32*, i32** %w, align 4, !dbg !42
+ ret i32* %5, !dbg !43
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!12, !13}
+!llvm.ident = !{!14}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
+!1 = !DIFile(filename: "test.c", directory: "/home/vk/repos/tmp/dwarf")
+!2 = !{}
+!3 = !{!4, !8}
+!4 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 20, type: !5, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7, !7, !7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!8 = distinct !DISubprogram(name: "f3", scope: !1, file: !1, line: 27, type: !9, isLocal: false, isDefinition: true, scopeLine: 27, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !7, !7}
+!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32, align: 32)
+!12 = !{i32 2, !"Dwarf Version", i32 4}
+!13 = !{i32 2, !"Debug Info Version", i32 3}
+!14 = !{!"clang version 3.8.0 (trunk 251783) (llvm/trunk 251781)"}
+!15 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 20, type: !7)
+!16 = !DIExpression()
+!17 = !DILocation(line: 20, column: 12, scope: !4)
+!18 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 20, type: !7)
+!19 = !DILocation(line: 20, column: 19, scope: !4)
+!20 = !DILocalVariable(name: "c", scope: !4, file: !1, line: 21, type: !7)
+!21 = !DILocation(line: 21, column: 7, scope: !4)
+!22 = !DILocation(line: 21, column: 40, scope: !4)
+!23 = !DILocation(line: 21, column: 44, scope: !4)
+!24 = !DILocation(line: 21, column: 42, scope: !4)
+!25 = !DILocation(line: 22, column: 3, scope: !4)
+!26 = !DILocation(line: 23, column: 10, scope: !4)
+!27 = !DILocation(line: 23, column: 3, scope: !4)
+!28 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 27, type: !7)
+!29 = !DILocation(line: 27, column: 13, scope: !8)
+!30 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 27, type: !7)
+!31 = !DILocation(line: 27, column: 20, scope: !8)
+!32 = !DILocalVariable(name: "c", scope: !8, file: !1, line: 28, type: !7)
+!33 = !DILocation(line: 28, column: 7, scope: !8)
+!34 = !DILocation(line: 28, column: 40, scope: !8)
+!35 = !DILocation(line: 28, column: 44, scope: !8)
+!36 = !DILocation(line: 28, column: 42, scope: !8)
+!37 = !DILocalVariable(name: "w", scope: !8, file: !1, line: 29, type: !11)
+!38 = !DILocation(line: 29, column: 8, scope: !8)
+!39 = !DILocation(line: 29, column: 19, scope: !8)
+!40 = !DILocation(line: 29, column: 12, scope: !8)
+!41 = !DILocation(line: 30, column: 3, scope: !8)
+!42 = !DILocation(line: 31, column: 10, scope: !8)
+!43 = !DILocation(line: 31, column: 3, scope: !8)