[llvm] [llvm-profgen] Trim tail CR+LF for LBR record line (PR #93210)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 19:07:21 PDT 2024


WenleiHe wrote:

> > LGTM, might be helpful to have a test case protecting against it since most of us don't have windows environment.
> 
> I'm not going to add a test since rtrim() will not do anything bad. The warning message only prints the whole line: `warning: Invalid address in LBR record at line xxx`
> 
> The reason is if we run llvm-profgen on Linux with perfscript generated by sep on Windows, StringRef treats '\n' as EOL and '\r' as a normal char so that profgen try to parse '\r' as LBR record. That would not be problem when running llvm-profgen on Windows. See
> 
> https://github.com/llvm/llvm-project/blob/06aadbeb2538c3e28cca7c82db102dffc7bdc269/llvm/include/llvm/ADT/StringRef.h#L84

It's fine if we don't have test case for this small change. By protecting, what I mean is making sure if someone removes the rtrim later on (likely unintentionally with refactoring etc.), something will fail. 

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


More information about the llvm-commits mailing list