Reapply "Avoid emitting redundant or unusable directories in DIFile metadata entries.""
authorAdrian Prantl <aprantl@apple.com>
Thu, 6 Dec 2018 18:44:50 +0000 (18:44 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 6 Dec 2018 18:44:50 +0000 (18:44 +0000)
commit212c104ea3c834aa895c8baea471ecc6f539d47c
treefd73cbf4fb70f1d94a50d773b8b9b72bd02cd341
parentfbeeac0e1e96ae36f65bb17424ef0fe00a95d8ed
Reapply "Avoid emitting redundant or unusable directories in DIFile metadata entries.""

This reverts commit r348280 and reapplies D55085 without modifications.

Original commit message:

    Avoid emitting redundant or unusable directories in DIFile metadata entries.

    As discussed on llvm-dev recently, Clang currently emits redundant
    directories in DIFile entries, such as

      .file      1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

    This patch looks at any common prefix between the compilation
    directory and the (absolute) file path and strips the redundant
    part. More importantly it leaves the compilation directory empty if
    the two paths have no common prefix.

    After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"):

      .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"

    When building the FileCheck binary with debug info, this patch makes
    the build artifacts ~1kb smaller.

    Differential Revision: https://reviews.llvm.org/D55085

llvm-svn: 348513
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/CodeGen/debug-info-abspath.c [new file with mode: 0644]
clang/test/CodeGen/debug-prefix-map.c
clang/test/Modules/module-debuginfo-prefix.m