================
@@ -163,21 +163,34 @@ void writeVar(uint32_t I, llvm::raw_ostream &OS) {
// These are sorted to improve compression.
// Maps each string to a canonical representation.
-// Strings remain owned externally (e.g. by SymbolSlab).
+// Strings remain owned externally (e.g. by SymbolSlab), except for strings
+// that are transformed by path remapping.
class StringTableOut {
llvm::DenseSet<llvm::StringRef> Unique;
std::vector<llvm::StringRef> Sorted;
// Since strings are interned, look up can be by pointer.
llvm::DenseMap<std::pair<const char *, size_t>, unsigned> Index;
+ llvm::BumpPtrAllocator Arena;
+ llvm::StringSaver TransformSaver{Arena};
+ const PathTransform *Transform = nullptr;
public:
StringTableOut() {
// Ensure there's at least one string in the table.
// Table size zero is reserved to indicate no compression.
Unique.insert("");
}
+ void setTransform(const PathTransform *T) { Transform = T; }
// Add a string to the table. Overwrites S if an identical string exists.
- void intern(llvm::StringRef &S) { S = *Unique.insert(S).first; };
+ // If path remapping is enabled, transform and store the new value.
+ void intern(llvm::StringRef &S) {
+ if (Transform) {
+ std::string Transformed = (*Transform)(S);
+ if (Transformed != S)
----------------
ArcsinX wrote:
We do this comparison for every string in the table if transformation is
specified. And this independent on the "type" of string (we try to apply
transformation for symbol names, types, etc.)
Also, this looks not an efficient solution in a long run. If user specified
background path mappings, he will do such strings allocations and comparison at
every index load.
https://github.com/llvm/llvm-project/pull/180285
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits