[PATCH] D55085: Avoid emitting redundant or unusable directories in DIFile metadata entries

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 29 15:28:09 PST 2018


aprantl created this revision.
aprantl added reviewers: dblaikie, probinson.
aprantl added a project: debug-info.

As discussed on llvm-dev today, 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.


https://reviews.llvm.org/D55085

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-abspath.c
  test/CodeGen/debug-prefix-map.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55085.175975.patch
Type: text/x-patch
Size: 4679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181129/01a67255/attachment-0001.bin>


More information about the cfe-commits mailing list