[clang-tools-extra] [llvm] [compiler-rt] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 10 21:04:55 PST 2023


================
@@ -144,25 +145,27 @@ void GlobalObject::copyAttributesFrom(const GlobalObject *Src) {
 std::string GlobalValue::getGlobalIdentifier(StringRef Name,
                                              GlobalValue::LinkageTypes Linkage,
                                              StringRef FileName) {
-
   // Value names may be prefixed with a binary '1' to indicate
   // that the backend should not modify the symbols due to any platform
   // naming convention. Do not include that '1' in the PGO profile name.
   if (Name[0] == '\1')
     Name = Name.substr(1);
 
-  std::string NewName = std::string(Name);
+  SmallString<64> GlobalName;
----------------
MaskRay wrote:

If Name is longer than 64, this would cause two head allocations. It might be better to stick with `std::string`.

https://github.com/llvm/llvm-project/pull/74008


More information about the cfe-commits mailing list