[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 15:18:00 PDT 2023


MaskRay marked 2 inline comments as done.
MaskRay added inline comments.


================
Comment at: clang/include/clang/Basic/CodeGenOptions.h:209
 
-  std::map<std::string, std::string> DebugPrefixMap;
+  llvm::SmallVector<std::pair<std::string, std::string>, 0> DebugPrefixMap;
   std::map<std::string, std::string> CoveragePrefixMap;
----------------
scott.linder wrote:
> What benefit does forcing allocation have? Why not use the default, or switch to `std::vector`?
This doesn't force allocation. I use inline element size 0 to make the member variable smaller than a `std::vector`.
`std::vector` likely compiles to larger code.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:72-79
 CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
     : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
       DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
       DBuilder(CGM.getModule()) {
-  for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap)
-    DebugPrefixMap[KV.first] = KV.second;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().DebugPrefixMap)
+    DebugPrefixMap.emplace_back(From, To);
   CreateCompileUnit();
----------------
scott.linder wrote:
> Can you use the member-initializer-list here?
No, this doesn't work. We convert a vector of `std::string` to a vector of `StringRef`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975



More information about the cfe-commits mailing list