[PATCH] D90265: [llvm][StringExtras] Add a fail-able version of `fromHex` and optimize hex digit lookup
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 27 14:17:27 PDT 2020
rriddle created this revision.
rriddle added reviewers: phosek, mehdi_amini.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
rriddle requested review of this revision.
Herald added a subscriber: stephenneuendorffer.
This revision adds a fail-able/checked version of `fromHex` that fails when the input string contains a non-hex character. This removes the need for users to have a separate check for if the string contains all hex digits. This becomes very costly for large hex strings given that checking if a string contains only hex digits is effectively the same as just converting it in the first place.
This revision also refactors `hexDigitValue` to use a lookup table instead of if statements, which also leads to a large speedup of hex conversion.
Context: In MLIR we use hex strings to represent very large constants in the textual format of the IR. These changes lead to a large decrease in compile time when parsing these constants (2 seconds -> 300 miliseconds).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90265
Files:
llvm/include/llvm/ADT/StringExtras.h
llvm/unittests/ADT/StringExtrasTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90265.301098.patch
Type: text/x-patch
Size: 5219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/d6aed022/attachment.bin>
More information about the llvm-commits
mailing list