Skip to content

Commit 3922ec4

Browse files
dankmMaskRay
authored andcommitted
[MCContext] Reverse order of DebugPrefixMap sort for generated assembly debug info
Match Clang's sorting, so that longer (more specific) prefix paths will match before less specific paths. Reviewed By: MaskRay, raj.khem, #debug-info Differential Revision: https://reviews.llvm.org/D132390
1 parent 2887d77 commit 3922ec4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/include/llvm/MC/MCContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class MCContext {
190190
SmallString<128> CompilationDir;
191191

192192
/// Prefix replacement map for source file information.
193-
std::map<const std::string, const std::string> DebugPrefixMap;
193+
std::map<std::string, const std::string, std::greater<std::string>>
194+
DebugPrefixMap;
194195

195196
/// The main file name if passed in explicitly.
196197
std::string MainFileName;

llvm/test/MC/ELF/debug-prefix-map.s

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# RUN: rm -rf %t.foo && mkdir %t.foo && cd %t.foo
2-
# RUN: cp %s %t.foo/src.s
1+
# RUN: rm -rf %t.foo && mkdir -p %t.foo/bar && cd %t.foo
2+
# RUN: cp %s %t.foo/src.s && cp %s %t.foo/bar/src.s
33

44
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 src.s -filetype=obj -o nomap.4.o
55
# RUN: llvm-dwarfdump -v -debug-info -debug-line nomap.4.o | FileCheck --check-prefix=NO_MAP_V4 %s
@@ -11,9 +11,10 @@
1111
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 src.s -filetype=obj -o map.5.o -fdebug-prefix-map=%t.foo=src_root
1212
# RUN: llvm-dwarfdump -v -debug-info -debug-line map.5.o | FileCheck --check-prefix=MAP_V5 %s
1313

14-
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 %t.foo/src.s -filetype=obj -o mapabs.4.o -fdebug-prefix-map=%t.foo=/src_root
14+
# RUN: cd %t.foo/bar
15+
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.4.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
1516
# RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.4.o | FileCheck --check-prefix=MAPABS_V4 %s
16-
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo/src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo=/src_root
17+
# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root -fdebug-prefix-map=%t.foo=/broken_root
1718
# RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5 %s
1819

1920
f:

0 commit comments

Comments
 (0)