[DebugInfo] Fix tests so that each subprogram belongs to a CU.

llvm-svn: 265490
diff --git a/llvm/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll b/llvm/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
index 24ceaa4..09706c2 100644
--- a/llvm/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
+++ b/llvm/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
@@ -22,6 +22,8 @@
   ret i32 4, !dbg !DILocation(scope: !1)
 }
 
+!llvm.dbg.cu = !{!6}
+
 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
 
 !7 = !{!1}
@@ -33,7 +35,7 @@
 !4 = !{!5}
 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
 !8 = !DIFile(filename: "/d/j/debug-test.c", directory: "/Volumes/Data/b")
-!9 = !{i32 0}
+!9 = !{}
 
 !llvm.module.flags = !{!10}
 !10 = !{i32 1, !"Debug Info Version", i32 3}
diff --git a/llvm/test/Assembler/metadata.ll b/llvm/test/Assembler/metadata.ll
index 8c7781e..ee998e3 100644
--- a/llvm/test/Assembler/metadata.ll
+++ b/llvm/test/Assembler/metadata.ll
@@ -2,7 +2,7 @@
 ; RUN: verify-uselistorder %s
 
 ; CHECK-LABEL: @test
-; CHECK: ret void, !bar !1, !foo !0
+; CHECK: ret void, !bar !4, !foo !5
 define void @test() {
   add i32 2, 1, !bar !0
   add i32 1, 2, !foo !1
@@ -11,29 +11,38 @@
   ret void, !foo !0, !bar !1
 }
 
-; CHECK-LABEL: define void @test2() !foo !2 !baz !3
+; CHECK-LABEL: define void @test2() !foo !6 !baz !7
 define void @test2() !foo !2 !baz !3 {
   unreachable
 }
 
-; CHECK-LABEL: define void @test3() !bar !3
-; CHECK: unreachable, !bar !4
+; CHECK-LABEL: define void @test3() !bar !7
+; CHECK: unreachable, !bar !8
 define void @test3() !bar !3 {
   unreachable, !bar !4
 }
 
 ; CHECK-LABEL: define void @test_attachment_name() {
-; CHECK:   unreachable, !\342abc !4
+; CHECK:   unreachable, !\342abc !8
 define void @test_attachment_name() {
   ;; Escape the first character when printing text IR, since it's a digit
   unreachable, !\34\32abc !4
 }
 
+!llvm.module.flags = !{!7}
+!llvm.dbg.cu = !{!5}
 !0 = !DILocation(line: 662302, column: 26, scope: !1)
 !1 = distinct !DISubprogram(name: "foo")
 !2 = distinct !{}
 !3 = distinct !{}
 !4 = distinct !{}
+!5 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !6,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!1})
+!6 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
+!7 = !{i32 2, !"Debug Info Version", i32 3}
 
 declare void @llvm.dbg.func.start(metadata) nounwind readnone
 
diff --git a/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir b/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
index b852dea..d30ee39 100644
--- a/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
+++ b/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
@@ -31,7 +31,8 @@
   !llvm.dbg.cu = !{!0}
   !llvm.module.flags = !{!3}
 
-  !0 = distinct !DICompileUnit(language: DW_LANG_C89, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
+  !0 = distinct !DICompileUnit(language: DW_LANG_C89, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2,
+                               subprograms: !{!5})
   !1 = !DIFile(filename: "t.c", directory: "")
   !2 = !{}
   !3 = !{i32 1, !"Debug Info Version", i32 3}
@@ -52,8 +53,8 @@
   maxAlignment:    16
 # CHECK-LABEL: foo
 # CHECK: stack:
-# CHECK:  - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!4',
-# CHECK-NEXT: di-expression: '!10', di-location: '!11' }
+# CHECK:  - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!6',
+# CHECK-NEXT: di-expression: '!11', di-location: '!12' }
 stack:
   - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!4',
       di-expression: '!7', di-location: '!8' }
diff --git a/llvm/test/CodeGen/Thumb/2010-07-15-debugOrdering.ll b/llvm/test/CodeGen/Thumb/2010-07-15-debugOrdering.ll
index 5058ad32..18bed61 100644
--- a/llvm/test/CodeGen/Thumb/2010-07-15-debugOrdering.ll
+++ b/llvm/test/CodeGen/Thumb/2010-07-15-debugOrdering.ll
@@ -53,7 +53,7 @@
 !2 = distinct !DILexicalBlock(line: 44, column: 0, file: !101, scope: !3)
 !3 = distinct !DISubprogram(name: "getClosestDiagonal3", linkageName: "_Z19getClosestDiagonal3ii", line: 44, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, file: !101, scope: null, type: !6)
 !4 = !DIFile(filename: "ggEdgeDiscrepancy.cc", directory: "/Volumes/Home/grosbaj/sources/llvm-externals/speccpu2000/benchspec/CINT2000/252.eon/src")
-!5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build 00)", isOptimized: true, emissionKind: FullDebug, file: !101, enums: !102, retainedTypes: !102, subprograms: !103)
+!5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build 00)", isOptimized: true, emissionKind: FullDebug, file: !101, enums: !102, retainedTypes: !102, subprograms: !{!3, !37, !41, !42, !77})
 !6 = !DISubroutineType(types: !7)
 !7 = !{!8, !22, !22}
 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "ggVector3", line: 66, size: 192, align: 32, file: !99, elements: !10)
diff --git a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
index 71dca94..54f2c35 100644
--- a/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
+++ b/llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
@@ -2022,6 +2022,7 @@
 ; CHECK: call void @__tsan_atomic_thread_fence(i32 5), !dbg
 
 !llvm.module.flags = !{!0, !1, !2}
+!llvm.dbg.cu = !{!8}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = !{i32 1, !"PIC Level", i32 2}
@@ -2031,3 +2032,9 @@
 !5 = !DIFile(filename: "atomic.cpp", directory: "/tmp")
 !6 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 99, type: !4, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, variables: !3)
 !7 = !DILocation(line: 100, column: 1, scope: !6)
+
+!8 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !5,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!6})
diff --git a/llvm/test/Transforms/GVN/load-pre-nonlocal.ll b/llvm/test/Transforms/GVN/load-pre-nonlocal.ll
index e0e8866..70bf492 100644
--- a/llvm/test/Transforms/GVN/load-pre-nonlocal.ll
+++ b/llvm/test/Transforms/GVN/load-pre-nonlocal.ll
@@ -92,6 +92,7 @@
 !6 = !{!"int", !3, i64 0}
 
 !llvm.module.flags = !{!7, !8, !9}
+!llvm.dbg.cu = !{!18}
 !7 = !{i32 2, !"Dwarf Version", i32 4}
 !8 = !{i32 2, !"Debug Info Version", i32 3}
 !9 = !{i32 1, !"PIC Level", i32 2}
@@ -104,4 +105,8 @@
 !15 = !DILocation(line: 101, column: 1, scope: !13)
 !16 = !DILocation(line: 102, column: 1, scope: !13)
 !17 = !DILocation(line: 103, column: 1, scope: !13)
-
+!18 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !12,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!13})
diff --git a/llvm/test/Transforms/GVN/phi-translate.ll b/llvm/test/Transforms/GVN/phi-translate.ll
index 67036ab..281e88f 100644
--- a/llvm/test/Transforms/GVN/phi-translate.ll
+++ b/llvm/test/Transforms/GVN/phi-translate.ll
@@ -37,6 +37,7 @@
 }
 
 !llvm.module.flags = !{!0, !1, !2}
+!llvm.dbg.cu = !{!12}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = !{i32 1, !"PIC Level", i32 2}
@@ -50,3 +51,8 @@
 !9 = !DILocation(line: 45, column: 1, scope: !6)
 !10 = !DILocation(line: 46, column: 1, scope: !6)
 !11 = !DILocation(line: 47, column: 1, scope: !6)
+!12 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !5,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!6})
diff --git a/llvm/test/Transforms/Inline/debug-invoke.ll b/llvm/test/Transforms/Inline/debug-invoke.ll
index c547559..b1cb9ea 100644
--- a/llvm/test/Transforms/Inline/debug-invoke.ll
+++ b/llvm/test/Transforms/Inline/debug-invoke.ll
@@ -31,7 +31,15 @@
 }
 
 !llvm.module.flags = !{!1}
+!llvm.dbg.cu = !{!5}
+
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = distinct !DISubprogram()
 !3 = !DILocation(line: 1, scope: !2)
 !4 = !DILocation(line: 2, scope: !2)
+!5 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !6,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!2})
+!6 = !DIFile(filename: "path/davidino", directory: "/path/to/dir")
diff --git a/llvm/test/Transforms/LoopSimplify/dbg-loc.ll b/llvm/test/Transforms/LoopSimplify/dbg-loc.ll
index b0e14bb..23a6048 100644
--- a/llvm/test/Transforms/LoopSimplify/dbg-loc.ll
+++ b/llvm/test/Transforms/LoopSimplify/dbg-loc.ll
@@ -73,6 +73,7 @@
 ; CHECK-DAG: [[LPAD_PREHEADER_LOC]] = !DILocation(line: 85, column: 1, scope: !{{[0-9]+}})
 
 !llvm.module.flags = !{!0, !1, !2}
+!llvm.dbg.cu = !{!14}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = !{i32 1, !"PIC Level", i32 2}
@@ -88,3 +89,8 @@
 !11 = !DILocation(line: 73, column: 46, scope: !6)
 !12 = !DILocation(line: 75, column: 9, scope: !6)
 !13 = !DILocation(line: 85, column: 1, scope: !6)
+!14 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !5,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!6})
diff --git a/llvm/test/Transforms/LoopSimplify/single-backedge.ll b/llvm/test/Transforms/LoopSimplify/single-backedge.ll
index 6f3db8f..40e903e 100644
--- a/llvm/test/Transforms/LoopSimplify/single-backedge.ll
+++ b/llvm/test/Transforms/LoopSimplify/single-backedge.ll
@@ -24,6 +24,7 @@
 }
 
 !llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!12}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 
@@ -37,3 +38,8 @@
 !9 = !DILocation(line: 103, column: 1, scope: !5)
 !10 = !DILocation(line: 104, column: 1, scope: !5)
 !11 = !DILocation(line: 105, column: 1, scope: !5)
+!12 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !4,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!5})
diff --git a/llvm/test/Transforms/LoopUnroll/runtime-loop1.ll b/llvm/test/Transforms/LoopUnroll/runtime-loop1.ll
index b8ab3ca..a5dfb55 100644
--- a/llvm/test/Transforms/LoopUnroll/runtime-loop1.ll
+++ b/llvm/test/Transforms/LoopUnroll/runtime-loop1.ll
@@ -53,6 +53,7 @@
 }
 
 !llvm.module.flags = !{!0, !1, !2}
+!llvm.dbg.cu = !{!11}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = !{i32 1, !"PIC Level", i32 2}
@@ -65,3 +66,8 @@
 !8 = !DILocation(line: 101, column: 1, scope: !6)
 !9 = !DILocation(line: 102, column: 1, scope: !6)
 !10 = !DILocation(line: 103, column: 1, scope: !6)
+!11 =  distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !5,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2, 
+                             subprograms: !{!6}) 
diff --git a/llvm/test/Transforms/LoopVectorize/X86/no_fpmath.ll b/llvm/test/Transforms/LoopVectorize/X86/no_fpmath.ll
index 0bb78ce..eee6dd8 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/no_fpmath.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/no_fpmath.ll
@@ -71,6 +71,7 @@
 
 attributes #0 = { nounwind }
 
+!llvm.dbg.cu = !{!28}
 !llvm.module.flags = !{!0, !1}
 !llvm.ident = !{!2}
 
@@ -102,3 +103,8 @@
 !25 = !DILocation(line: 17, column: 11, scope: !20)
 !26 = distinct !{!26, !27, !18}
 !27 = !{!"llvm.loop.vectorize.enable", i1 true}
+!28 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !5,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2, 
+                             subprograms: !{!4, !20})
diff --git a/llvm/test/Transforms/LoopVectorize/runtime-check.ll b/llvm/test/Transforms/LoopVectorize/runtime-check.ll
index 3673b71..02751e4 100644
--- a/llvm/test/Transforms/LoopVectorize/runtime-check.ll
+++ b/llvm/test/Transforms/LoopVectorize/runtime-check.ll
@@ -67,6 +67,7 @@
 ; CHECK: [[BODY_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
 
 !llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!9}
 !0 = !{i32 2, !"Dwarf Version", i32 4}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 
@@ -77,3 +78,10 @@
 !6 = !DILocation(line: 100, column: 1, scope: !5)
 !7 = !DILocation(line: 101, column: 1, scope: !5)
 !8 = !DILocation(line: 102, column: 1, scope: !5)
+!9 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !10,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!5})
+!10 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
+!11 = !{i32 2, !"Debug Info Version", i32 3}
diff --git a/llvm/test/Transforms/ObjCARC/basic.ll b/llvm/test/Transforms/ObjCARC/basic.ll
index a6fdf5e..61f027c 100644
--- a/llvm/test/Transforms/ObjCARC/basic.ll
+++ b/llvm/test/Transforms/ObjCARC/basic.ll
@@ -3037,10 +3037,18 @@
 }
 
 !llvm.module.flags = !{!1}
+!llvm.dbg.cu = !{!3}
 
 !0 = !{}
 !1 = !{i32 1, !"Debug Info Version", i32 3}
 !2 = distinct !DISubprogram()
+!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
+                             file: !4,
+                             isOptimized: true, flags: "-O2",
+                             splitDebugFilename: "abc.debug", emissionKind: 2,
+                             subprograms: !{!2})
+!4 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
+!5 = !{i32 2, !"Debug Info Version", i32 3}
 
 ; CHECK: attributes #0 = { nounwind readnone }
 ; CHECK: attributes [[NUW]] = { nounwind }