[llvm] 91337e9 - Handle whitespace in symbol list

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 18 12:34:51 PST 2022


Author: Chris Bieneman
Date: 2022-01-18T14:34:40-06:00
New Revision: 91337e9091707f1d190994a3494c2283091c8c10

URL: https://github.com/llvm/llvm-project/commit/91337e9091707f1d190994a3494c2283091c8c10
DIFF: https://github.com/llvm/llvm-project/commit/91337e9091707f1d190994a3494c2283091c8c10.diff

LOG: Handle whitespace in symbol list

Trimming whitespace or carriage returns from symbols allows this code
to work on Windows and makes it match other places symbol lists are
handled.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D117570

Added: 
    

Modified: 
    llvm/test/Transforms/SampleProfile/Inputs/profile-symbol-list.text
    llvm/tools/llvm-profdata/llvm-profdata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SampleProfile/Inputs/profile-symbol-list.text b/llvm/test/Transforms/SampleProfile/Inputs/profile-symbol-list.text
index f7a5f22cc8a2b..ca16a63dc88a3 100644
--- a/llvm/test/Transforms/SampleProfile/Inputs/profile-symbol-list.text
+++ b/llvm/test/Transforms/SampleProfile/Inputs/profile-symbol-list.text
@@ -7,4 +7,4 @@ _dl_relocate_static_pie
 _fini
 _init
 _start
-main
+ main

diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 0d7eabd6d1584..356dd5c48829a 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -661,8 +661,8 @@ static void populateProfileSymbolList(MemoryBuffer *Buffer,
   StringRef Data = Buffer->getBuffer();
   Data.split(SymbolVec, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
-  for (StringRef symbol : SymbolVec)
-    PSL.add(symbol);
+  for (StringRef SymbolStr : SymbolVec)
+    PSL.add(SymbolStr.trim());
 }
 
 static void handleExtBinaryWriter(sampleprof::SampleProfileWriter &Writer,


        


More information about the llvm-commits mailing list