Skip to content

[SandboxVec][NFC] Replace std::regex with llvm::Regex #134110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Apr 2, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-llvm-transforms

Author: vporpo (vporpo)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/134110.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp (+4-3)
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
index 20186426a5259..ed2f80ba8900a 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
@@ -11,9 +11,9 @@
 #include "llvm/IR/Module.h"
 #include "llvm/SandboxIR/Constant.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Regex.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Debug.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.h"
-#include <regex>
 
 using namespace llvm;
 
@@ -92,8 +92,9 @@ bool SandboxVectorizerPass::allowFile(const std::string &SrcFilePath) {
     if (FileNameToMatch.empty())
       return false;
     // Note: This only runs when debugging so its OK not to reuse the regex.
-    std::regex FileNameRegex(std::string(".*") + FileNameToMatch);
-    if (std::regex_match(SrcFilePath, FileNameRegex))
+    Regex FileNameRegex(".*" + FileNameToMatch + "$");
+    assert(FileNameRegex.isValid() && "Bad regex!");
+    if (FileNameRegex.match(SrcFilePath))
       return true;
   } while (DelimPos != std::string::npos);
   return false;

vporpo referenced this pull request Apr 2, 2025
…29127)

This new option lets you specify an allow-list of source files and
disables vectorization if the IR is not in the list. This can be used
for debugging miscompiles.
Copy link
Collaborator

@danilaml danilaml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Assuming lit tests pass, LGTM.

@vporpo vporpo merged commit a1b0b49 into llvm:main Apr 2, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants