[llvm] Support for extension SPV_INTEL_latency_control. (PR #133397)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 03:27:36 PDT 2025


================
@@ -213,14 +213,19 @@ static SmallVector<Metadata *> parseAnnotation(Value *I,
         break;
       if (Item[0] == '"') {
         Item = Item.substr(1, Item.length() - 2);
-        // Acceptable format of the string snippet is:
-        static const std::regex RStr("^(\\d+)(?:,(\\d+))*$");
-        if (std::smatch MatchStr; std::regex_match(Item, MatchStr, RStr)) {
-          for (std::size_t SubIdx = 1; SubIdx < MatchStr.size(); ++SubIdx)
-            if (std::string SubStr = MatchStr[SubIdx].str(); SubStr.length())
-              MDsItem.push_back(ConstantAsMetadata::get(
-                  ConstantInt::get(Int32Ty, std::stoi(SubStr))));
-        } else {
+        static const std::regex NumberRegex(R"(\b\d+\b)");
+        std::sregex_token_iterator It(Item.begin(), Item.end(), NumberRegex);
+        std::sregex_token_iterator End;
----------------
swatheesh-mcw wrote:

Do we need to initialize the End Iterator here as it is used inside while loop?

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


More information about the llvm-commits mailing list