]> granicus.if.org Git - llvm/commitdiff
dsymutil: don't copy compile units without children from PCM files
authorAdrian Prantl <aprantl@apple.com>
Tue, 22 Aug 2017 01:10:48 +0000 (01:10 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 22 Aug 2017 01:10:48 +0000 (01:10 +0000)
rdar://problem/33830532

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311416 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/dsymutil/Inputs/modules-empty/1.o [new file with mode: 0644]
test/tools/dsymutil/Inputs/modules-empty/Empty.pcm [new file with mode: 0644]
test/tools/dsymutil/X86/modules-empty.m [new file with mode: 0644]
tools/dsymutil/DwarfLinker.cpp

diff --git a/test/tools/dsymutil/Inputs/modules-empty/1.o b/test/tools/dsymutil/Inputs/modules-empty/1.o
new file mode 100644 (file)
index 0000000..1958835
Binary files /dev/null and b/test/tools/dsymutil/Inputs/modules-empty/1.o differ
diff --git a/test/tools/dsymutil/Inputs/modules-empty/Empty.pcm b/test/tools/dsymutil/Inputs/modules-empty/Empty.pcm
new file mode 100644 (file)
index 0000000..a1de19e
Binary files /dev/null and b/test/tools/dsymutil/Inputs/modules-empty/Empty.pcm differ
diff --git a/test/tools/dsymutil/X86/modules-empty.m b/test/tools/dsymutil/X86/modules-empty.m
new file mode 100644 (file)
index 0000000..3d95aa1
--- /dev/null
@@ -0,0 +1,28 @@
+/* Compile with:
+   cat >modules.modulemap <<EOF
+     module Empty {
+       header "Empty.h"
+     }
+EOF
+   touch Empty.h
+   clang -c -fmodules -fmodule-map-file=modules.modulemap \
+     -g -gmodules -fmodules-cache-path=. \
+     -Xclang -fdisable-module-hash modules-empty.m -o 1.o
+*/
+
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+// RUN: cp %p/../Inputs/modules-empty/1.o %p/../Inputs/modules-empty/Empty.pcm %t.dir
+// RUN: llvm-dsymutil -f -oso-prepend-path=%t.dir \
+// RUN:   -y %p/dummy-debug-map.map -o - \
+// RUN:     | llvm-dwarfdump --debug-dump=info - | FileCheck %s
+
+#include "Empty.h"
+int main() {
+  return 0;
+}
+
+// The empty CU from the pcm should not get copied into the dSYM.
+// CHECK: DW_TAG_compile_unit
+// CHECK-NOT: DW_TAG_compile_unit
+
index f9328e42fd04d78203028be33424ccdf0ad4a848..6b5415a0795e93005d6d74e28d7ce97833a7756c 100644 (file)
@@ -3358,6 +3358,8 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
       Unit->markEverythingAsKept();
     }
   }
+  if (!Unit->getOrigUnit().getUnitDIE().hasChildren())
+    return;
   if (Options.Verbose) {
     outs().indent(Indent);
     outs() << "cloning .debug_info from " << Filename << "\n";