-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[SandboxVec][SeedCollector][NFC] Replace cl::opt flags with constructor args #143206
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
Conversation
|
@llvm/pr-subscribers-llvm-transforms Author: vporpo (vporpo) ChangesThe Full diff: https://github.com/llvm/llvm-project/pull/143206.diff 4 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
index 9c1374719298b..c9e4d8dc00680 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
@@ -300,7 +300,8 @@ class SeedCollector {
}
public:
- SeedCollector(BasicBlock *BB, ScalarEvolution &SE);
+ SeedCollector(BasicBlock *BB, ScalarEvolution &SE, bool CollectStores,
+ bool CollectLoads);
~SeedCollector();
iterator_range<SeedContainer::iterator> getStoreSeeds() {
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
index f3b62e36e5115..ddb4a1e154a18 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
@@ -24,6 +24,13 @@ static cl::opt<bool>
AllowNonPow2("sbvec-allow-non-pow2", cl::init(false), cl::Hidden,
cl::desc("Allow non-power-of-2 vectorization."));
+#define LoadSeedsDef "loads"
+#define StoreSeedsDef "stores"
+cl::opt<std::string> CollectSeeds(
+ "sbvec-collect-seeds", cl::init(StoreSeedsDef), cl::Hidden,
+ cl::desc("Collect these seeds. Use empty for none or a comma-separated "
+ "list of '" StoreSeedsDef "' and '" LoadSeedsDef "'."));
+
namespace sandboxir {
SeedCollection::SeedCollection(StringRef Pipeline)
: FunctionPass("seed-collection"),
@@ -38,10 +45,12 @@ bool SeedCollection::runOnFunction(Function &F, const Analyses &A) {
: A.getTTI()
.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
+ bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
+ bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;
// TODO: Start from innermost BBs first
for (auto &BB : F) {
- SeedCollector SC(&BB, A.getScalarEvolution());
+ SeedCollector SC(&BB, A.getScalarEvolution(), CollectStores, CollectLoads);
for (SeedBundle &Seeds : SC.getStoreSeeds()) {
unsigned ElmBits =
Utils::getNumBits(VecUtils::getElementType(Utils::getExpectedType(
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
index ee7063437a8fc..eccd34698f2f8 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
@@ -20,12 +20,7 @@ namespace llvm::sandboxir {
static cl::opt<unsigned> SeedBundleSizeLimit(
"sbvec-seed-bundle-size-limit", cl::init(32), cl::Hidden,
cl::desc("Limit the size of the seed bundle to cap compilation time."));
-#define LoadSeedsDef "loads"
-#define StoreSeedsDef "stores"
-static cl::opt<std::string> CollectSeeds(
- "sbvec-collect-seeds", cl::init(LoadSeedsDef "," StoreSeedsDef), cl::Hidden,
- cl::desc("Collect these seeds. Use empty for none or a comma-separated "
- "list of '" LoadSeedsDef "' and '" StoreSeedsDef "'."));
+
static cl::opt<unsigned> SeedGroupsLimit(
"sbvec-seed-groups-limit", cl::init(256), cl::Hidden,
cl::desc("Limit the number of collected seeds groups in a BB to "
@@ -160,11 +155,10 @@ template <typename LoadOrStoreT> static bool isValidMemSeed(LoadOrStoreT *LSI) {
template bool isValidMemSeed<LoadInst>(LoadInst *LSI);
template bool isValidMemSeed<StoreInst>(StoreInst *LSI);
-SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE)
+SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
+ bool CollectStores, bool CollectLoads)
: StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext()) {
- bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
- bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;
if (!CollectStores && !CollectLoads)
return;
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
index 99a13801c7c33..78b794295bbc7 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
@@ -315,7 +315,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 4);
@@ -359,7 +360,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 4);
@@ -419,7 +421,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0, i64 %val1) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 3);
@@ -460,7 +463,8 @@ define void @foo(ptr noalias %ptr, float %v, <2 x float> %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 3);
@@ -503,7 +507,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/false,
+ /*CollectLoads=*/true);
// Find the loads
auto It = std::next(BB->begin(), 2);
|
|
@llvm/pr-subscribers-vectorizers Author: vporpo (vporpo) ChangesThe Full diff: https://github.com/llvm/llvm-project/pull/143206.diff 4 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
index 9c1374719298b..c9e4d8dc00680 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h
@@ -300,7 +300,8 @@ class SeedCollector {
}
public:
- SeedCollector(BasicBlock *BB, ScalarEvolution &SE);
+ SeedCollector(BasicBlock *BB, ScalarEvolution &SE, bool CollectStores,
+ bool CollectLoads);
~SeedCollector();
iterator_range<SeedContainer::iterator> getStoreSeeds() {
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
index f3b62e36e5115..ddb4a1e154a18 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/SeedCollection.cpp
@@ -24,6 +24,13 @@ static cl::opt<bool>
AllowNonPow2("sbvec-allow-non-pow2", cl::init(false), cl::Hidden,
cl::desc("Allow non-power-of-2 vectorization."));
+#define LoadSeedsDef "loads"
+#define StoreSeedsDef "stores"
+cl::opt<std::string> CollectSeeds(
+ "sbvec-collect-seeds", cl::init(StoreSeedsDef), cl::Hidden,
+ cl::desc("Collect these seeds. Use empty for none or a comma-separated "
+ "list of '" StoreSeedsDef "' and '" LoadSeedsDef "'."));
+
namespace sandboxir {
SeedCollection::SeedCollection(StringRef Pipeline)
: FunctionPass("seed-collection"),
@@ -38,10 +45,12 @@ bool SeedCollection::runOnFunction(Function &F, const Analyses &A) {
: A.getTTI()
.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
+ bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
+ bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;
// TODO: Start from innermost BBs first
for (auto &BB : F) {
- SeedCollector SC(&BB, A.getScalarEvolution());
+ SeedCollector SC(&BB, A.getScalarEvolution(), CollectStores, CollectLoads);
for (SeedBundle &Seeds : SC.getStoreSeeds()) {
unsigned ElmBits =
Utils::getNumBits(VecUtils::getElementType(Utils::getExpectedType(
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
index ee7063437a8fc..eccd34698f2f8 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SeedCollector.cpp
@@ -20,12 +20,7 @@ namespace llvm::sandboxir {
static cl::opt<unsigned> SeedBundleSizeLimit(
"sbvec-seed-bundle-size-limit", cl::init(32), cl::Hidden,
cl::desc("Limit the size of the seed bundle to cap compilation time."));
-#define LoadSeedsDef "loads"
-#define StoreSeedsDef "stores"
-static cl::opt<std::string> CollectSeeds(
- "sbvec-collect-seeds", cl::init(LoadSeedsDef "," StoreSeedsDef), cl::Hidden,
- cl::desc("Collect these seeds. Use empty for none or a comma-separated "
- "list of '" LoadSeedsDef "' and '" StoreSeedsDef "'."));
+
static cl::opt<unsigned> SeedGroupsLimit(
"sbvec-seed-groups-limit", cl::init(256), cl::Hidden,
cl::desc("Limit the number of collected seeds groups in a BB to "
@@ -160,11 +155,10 @@ template <typename LoadOrStoreT> static bool isValidMemSeed(LoadOrStoreT *LSI) {
template bool isValidMemSeed<LoadInst>(LoadInst *LSI);
template bool isValidMemSeed<StoreInst>(StoreInst *LSI);
-SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE)
+SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
+ bool CollectStores, bool CollectLoads)
: StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext()) {
- bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
- bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;
if (!CollectStores && !CollectLoads)
return;
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
index 99a13801c7c33..78b794295bbc7 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
@@ -315,7 +315,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 4);
@@ -359,7 +360,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 4);
@@ -419,7 +421,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0, i64 %val1) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 3);
@@ -460,7 +463,8 @@ define void @foo(ptr noalias %ptr, float %v, <2 x float> %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
+ /*CollectLoads=*/false);
// Find the stores
auto It = std::next(BB->begin(), 3);
@@ -503,7 +507,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
- sandboxir::SeedCollector SC(&*BB, SE);
+ sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/false,
+ /*CollectLoads=*/true);
// Find the loads
auto It = std::next(BB->begin(), 2);
|
|
Ping. Not sure why the windows build bot was failing, I restarted the job. |
|
ping |
1 similar comment
|
ping |
bd74e6a to
c06ee4e
Compare
|
Rebased and fixed formatting. |
…or args The `SeedCollector` class gets two new arguments: `CollectStores` and `CollectLoads`. These replace the `sbvec-collect-seeds` cl::opt flag. This is done to help with reusing the SeedCollector class in a future pass. The cl::opt flag is moved to the seed collection pass: Passes/SeedCollection.cpp
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/13415 Here is the relevant piece of the build log for the reference |
The
SeedCollectorclass gets two new arguments:CollectStoresandCollectLoads. These replace thesbvec-collect-seedscl::opt flag. This is done to help with reusing the SeedCollector class in a future pass. The cl::opt flag is moved to the seed collection pass: Passes/SeedCollection.cpp