[PATCH] D148757: [clang] Follow user-provided order for prefix map

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 21 15:40:22 PDT 2023


MaskRay added a comment.

In D148757#4285735 <https://reviews.llvm.org/D148757#4285735>, @gulfem wrote:

> I compared Clang and GCC behavior.
> **1) Following user-specified prefix mapping order**
> GCC uses a linked list to store the prefix mappings, so it applies the prefix mappings based on the user-provided order.
> https://github.com/gcc-mirror/gcc/blob/master/gcc/file-prefix-map.cc#L27
> Whereas, Clang currently uses an `std::map`, which does **NOT** follow user-provided order.  So, Clang and GCC behavior do not match on that.
>
> **2) Applying multiple prefix mappings**
> Both Clang and GCC apply the first matching prefix mapping, and does not apply the following prefix mappings. So, they are consistent in that.
>
> https://github.com/gcc-mirror/gcc/blob/master/gcc/file-prefix-map.cc#L88
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CoverageMappingGen.cpp#L1653

Sorry, request changes as I think I see conflicting needs. Cc #debug-info <https://reviews.llvm.org/tag/debug-info/>

We have DebugPrefixMap and CoveragePrefixMap, and I think their order behavior should be the same.

D49466 <https://reviews.llvm.org/D49466> added `DebugPrefixMap` to Clang which prefers a long prefix.
D132390 <https://reviews.llvm.org/D132390> is a MC version of `DebugPrefixMap` that prefers a long prefix.

The current order of `CoveragePrefixMap` is definitely weird as it prefers a shorter prefix.
This patch is going to change the order to the command line option order, but it will be different from `DebugPrefixMap`.

Can `CoveragePrefixMap` be made to prefer a long prefix as `DebugPrefixMap` does?

> `-ffile-prefix-map==out/ to prepend out/ to any unmatched files`

This operation feels a bit strange to me...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148757/new/

https://reviews.llvm.org/D148757



More information about the cfe-commits mailing list