[llvm] 52dca6f - [SandboxVec] Boilerplate (#107431)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 13:38:42 PDT 2024
Author: vporpo
Date: 2024-09-05T13:38:39-07:00
New Revision: 52dca6ffae08fcd86cff32ab469870016a6aceb5
URL: https://github.com/llvm/llvm-project/commit/52dca6ffae08fcd86cff32ab469870016a6aceb5
DIFF: https://github.com/llvm/llvm-project/commit/52dca6ffae08fcd86cff32ab469870016a6aceb5.diff
LOG: [SandboxVec] Boilerplate (#107431)
This patch implements the new pass and registers it with the pass
manager. For context, this is a vectorizer that operates on Sandbox IR,
which is a transactional IR on top of LLVM IR.
Added:
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
llvm/test/Transforms/SandboxVectorizer/boilerplate.ll
Modified:
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Vectorize/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
new file mode 100644
index 00000000000000..0d4dbae44521eb
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
@@ -0,0 +1,31 @@
+//===- SandboxVectorizer.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZER_H
+#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZER_H
+
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/ScalarEvolution.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/SandboxIR/SandboxIR.h"
+
+namespace llvm {
+
+class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
+ TargetTransformInfo *TTI = nullptr;
+
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+ bool runImpl(Function &F);
+};
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZER_H
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index a22abed8051a11..7c0acc0745eba3 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -321,6 +321,7 @@
#include "llvm/Transforms/Vectorize/LoopIdiomVectorize.h"
#include "llvm/Transforms/Vectorize/LoopVectorize.h"
#include "llvm/Transforms/Vectorize/SLPVectorizer.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h"
#include "llvm/Transforms/Vectorize/VectorCombine.h"
#include <optional>
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index d6067089c6b5c1..a1324e81705669 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -453,6 +453,7 @@ FUNCTION_PASS("reassociate", ReassociatePass())
FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass())
FUNCTION_PASS("reg2mem", RegToMemPass())
FUNCTION_PASS("safe-stack", SafeStackPass(TM))
+FUNCTION_PASS("sandbox-vectorizer", SandboxVectorizerPass())
FUNCTION_PASS("scalarize-masked-mem-intrin", ScalarizeMaskedMemIntrinPass())
FUNCTION_PASS("scalarizer", ScalarizerPass())
FUNCTION_PASS("sccp", SCCPPass())
diff --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index 5c88d94d96622d..649faad48d71e5 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -3,6 +3,7 @@ add_llvm_component_library(LLVMVectorize
LoopIdiomVectorize.cpp
LoopVectorizationLegality.cpp
LoopVectorize.cpp
+ SandboxVectorizer/SandboxVectorizer.cpp
SLPVectorizer.cpp
Vectorize.cpp
VectorCombine.cpp
@@ -18,6 +19,7 @@ add_llvm_component_library(LLVMVectorize
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/Vectorize
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/Vectorize/SandboxVectorizer
DEPENDS
intrinsics_gen
@@ -27,4 +29,5 @@ add_llvm_component_library(LLVMVectorize
Core
Support
TransformUtils
+ SandboxIR
)
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
new file mode 100644
index 00000000000000..072a6606694a0f
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
@@ -0,0 +1,39 @@
+//===- SandboxVectorizer.cpp - Vectorizer based on Sandbox IR -------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+#define SV_NAME "sandbox-vectorizer"
+#define DEBUG_TYPE SV_NAME
+
+PreservedAnalyses SandboxVectorizerPass::run(Function &F,
+ FunctionAnalysisManager &AM) {
+ TTI = &AM.getResult<TargetIRAnalysis>(F);
+
+ bool Changed = runImpl(F);
+ if (!Changed)
+ return PreservedAnalyses::all();
+
+ PreservedAnalyses PA;
+ PA.preserveSet<CFGAnalyses>();
+ return PA;
+}
+
+bool SandboxVectorizerPass::runImpl(Function &F) {
+ LLVM_DEBUG(dbgs() << "SBVec: Analyzing " << F.getName() << ".\n");
+ sandboxir::Context Ctx(F.getContext());
+ // Create SandboxIR for `F`.
+ sandboxir::Function &SBF = *Ctx.createFunction(&F);
+ // TODO: Initialize SBVec Pass Manager
+ (void)SBF;
+
+ return false;
+}
diff --git a/llvm/test/Transforms/SandboxVectorizer/boilerplate.ll b/llvm/test/Transforms/SandboxVectorizer/boilerplate.ll
new file mode 100644
index 00000000000000..353659d41485fc
--- /dev/null
+++ b/llvm/test/Transforms/SandboxVectorizer/boilerplate.ll
@@ -0,0 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes=sandbox-vectorizer %s -S | FileCheck %s
+
+; This test checks that the pass was registered with the pass manager.
+; TODO: Remove this test once actual tests land.
+define void @boilerplate() {
+; CHECK-LABEL: define void @boilerplate() {
+; CHECK-NEXT: ret void
+;
+ ret void
+}
More information about the llvm-commits
mailing list