-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SandboxIR][Pass] Implement Analyses class #113962
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 Analyses class provides a way to pass around commonly used Analyses to SandboxIR passes throught Full diff: https://github.com/llvm/llvm-project/pull/113962.diff 11 Files Affected:
diff --git a/llvm/include/llvm/SandboxIR/Pass.h b/llvm/include/llvm/SandboxIR/Pass.h
index 5ed9d7442ee70c..fc2287ad514e99 100644
--- a/llvm/include/llvm/SandboxIR/Pass.h
+++ b/llvm/include/llvm/SandboxIR/Pass.h
@@ -12,11 +12,23 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
-namespace llvm::sandboxir {
+namespace llvm {
+
+class ScalarEvolution;
+
+namespace sandboxir {
class Function;
class Region;
+class Analyses {
+ ScalarEvolution &SE;
+
+public:
+ Analyses(ScalarEvolution &SE) : SE(SE) {}
+ ScalarEvolution &getScalarEvolution() const { return SE; }
+};
+
/// The base class of a Sandbox IR Pass.
class Pass {
protected:
@@ -52,7 +64,7 @@ class FunctionPass : public Pass {
/// \p Name can't contain any spaces or start with '-'.
FunctionPass(StringRef Name) : Pass(Name) {}
/// \Returns true if it modifies \p F.
- virtual bool runOnFunction(Function &F) = 0;
+ virtual bool runOnFunction(Function &F, const Analyses &A) = 0;
};
/// A pass that runs on a sandbox::Region.
@@ -61,9 +73,10 @@ class RegionPass : public Pass {
/// \p Name can't contain any spaces or start with '-'.
RegionPass(StringRef Name) : Pass(Name) {}
/// \Returns true if it modifies \p R.
- virtual bool runOnRegion(Region &R) = 0;
+ virtual bool runOnRegion(Region &R, const Analyses &A) = 0;
};
-} // namespace llvm::sandboxir
+} // namespace sandboxir
+} // namespace llvm
#endif // LLVM_SANDBOXIR_PASS_H
diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h
index e8221996bc8f04..77154cc7143454 100644
--- a/llvm/include/llvm/SandboxIR/PassManager.h
+++ b/llvm/include/llvm/SandboxIR/PassManager.h
@@ -208,7 +208,7 @@ class FunctionPassManager final
FunctionPassManager(StringRef Name, StringRef Pipeline,
CreatePassFunc CreatePass)
: PassManager(Name, Pipeline, CreatePass) {}
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
};
class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
@@ -217,7 +217,7 @@ class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
RegionPassManager(StringRef Name, StringRef Pipeline,
CreatePassFunc CreatePass)
: PassManager(Name, Pipeline, CreatePass) {}
- bool runOnRegion(Region &R) final;
+ bool runOnRegion(Region &R, const Analyses &A) final;
};
} // namespace llvm::sandboxir
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index 5cd47efd6b3462..2b0b3f8192c048 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -33,7 +33,7 @@ class BottomUpVec final : public FunctionPass {
public:
BottomUpVec(StringRef Pipeline);
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
void printPipeline(raw_ostream &OS) const final {
OS << getName() << "\n";
RPM.printPipeline(OS);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
index 75b9f42520156c..1025379770bac0 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
@@ -11,7 +11,7 @@ class Region;
class NullPass final : public RegionPass {
public:
NullPass() : RegionPass("null") {}
- bool runOnRegion(Region &R) final { return false; }
+ bool runOnRegion(Region &R, const Analyses &A) final { return false; }
};
} // namespace llvm::sandboxir
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
index 9d88bc82803847..cd11d4c1489268 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
@@ -12,7 +12,7 @@ namespace llvm::sandboxir {
class PrintInstructionCount final : public RegionPass {
public:
PrintInstructionCount() : RegionPass("null") {}
- bool runOnRegion(Region &R) final {
+ bool runOnRegion(Region &R, const Analyses &A) final {
outs() << "InstructionCount: " << std::distance(R.begin(), R.end()) << "\n";
return false;
}
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
index 3d82a61c90153a..3d738ac8917eff 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
@@ -26,7 +26,7 @@ class RegionsFromMetadata final : public FunctionPass {
public:
RegionsFromMetadata(StringRef Pipeline);
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
void printPipeline(raw_ostream &OS) const final {
OS << getName() << "\n";
RPM.printPipeline(OS);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
index b83744cf9e6cb6..03867df3d98084 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
@@ -10,6 +10,7 @@
#include <memory>
+#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/PassManager.h"
#include "llvm/SandboxIR/PassManager.h"
@@ -19,6 +20,7 @@ class TargetTransformInfo;
class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
TargetTransformInfo *TTI = nullptr;
+ ScalarEvolution *SE = nullptr;
// A pipeline of SandboxIR function passes run by the vectorizer.
sandboxir::FunctionPassManager FPM;
diff --git a/llvm/lib/SandboxIR/PassManager.cpp b/llvm/lib/SandboxIR/PassManager.cpp
index 3a1cfa1d367a2a..aaa49e0f6912b6 100644
--- a/llvm/lib/SandboxIR/PassManager.cpp
+++ b/llvm/lib/SandboxIR/PassManager.cpp
@@ -10,20 +10,20 @@
namespace llvm::sandboxir {
-bool FunctionPassManager::runOnFunction(Function &F) {
+bool FunctionPassManager::runOnFunction(Function &F, const Analyses &A) {
bool Change = false;
for (auto &Pass : Passes) {
- Change |= Pass->runOnFunction(F);
+ Change |= Pass->runOnFunction(F, A);
// TODO: run the verifier.
}
// TODO: Check ChangeAll against hashes before/after.
return Change;
}
-bool RegionPassManager::runOnRegion(Region &R) {
+bool RegionPassManager::runOnRegion(Region &R, const Analyses &A) {
bool Change = false;
for (auto &Pass : Passes) {
- Change |= Pass->runOnRegion(R);
+ Change |= Pass->runOnRegion(R, A);
// TODO: run the verifier.
}
// TODO: Check ChangeAll against hashes before/after.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index ede41cd661b559..66d631edfc4076 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -59,7 +59,7 @@ void BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl) {
void BottomUpVec::tryVectorize(ArrayRef<Value *> Bndl) { vectorizeRec(Bndl); }
-bool BottomUpVec::runOnFunction(Function &F) {
+bool BottomUpVec::runOnFunction(Function &F, const Analyses &A) {
Change = false;
// TODO: Start from innermost BBs first
for (auto &BB : F) {
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
index 5887d5e8bc2683..8e3f5b77429c5a 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
@@ -17,11 +17,11 @@ RegionsFromMetadata::RegionsFromMetadata(StringRef Pipeline)
: FunctionPass("regions-from-metadata"),
RPM("rpm", Pipeline, SandboxVectorizerPassBuilder::createRegionPass) {}
-bool RegionsFromMetadata::runOnFunction(Function &F) {
+bool RegionsFromMetadata::runOnFunction(Function &F, const Analyses &A) {
SmallVector<std::unique_ptr<sandboxir::Region>> Regions =
sandboxir::Region::createRegionsFromMD(F);
for (auto &R : Regions) {
- RPM.runOnRegion(*R);
+ RPM.runOnRegion(*R, A);
}
return false;
}
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
index c68f9482e337dd..96d825ed852fb2 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
@@ -51,6 +51,7 @@ SandboxVectorizerPass::~SandboxVectorizerPass() = default;
PreservedAnalyses SandboxVectorizerPass::run(Function &F,
FunctionAnalysisManager &AM) {
TTI = &AM.getResult<TargetIRAnalysis>(F);
+ SE = &AM.getResult<ScalarEvolutionAnalysis>(F);
bool Changed = runImpl(F);
if (!Changed)
@@ -82,5 +83,6 @@ bool SandboxVectorizerPass::runImpl(Function &LLVMF) {
// Create SandboxIR for LLVMF and run BottomUpVec on it.
sandboxir::Context Ctx(LLVMF.getContext());
sandboxir::Function &F = *Ctx.createFunction(&LLVMF);
- return FPM.runOnFunction(F);
+ sandboxir::Analyses A(*SE);
+ return FPM.runOnFunction(F, A);
}
|
@llvm/pr-subscribers-vectorizers Author: vporpo (vporpo) ChangesThe Analyses class provides a way to pass around commonly used Analyses to SandboxIR passes throught Full diff: https://github.com/llvm/llvm-project/pull/113962.diff 11 Files Affected:
diff --git a/llvm/include/llvm/SandboxIR/Pass.h b/llvm/include/llvm/SandboxIR/Pass.h
index 5ed9d7442ee70c..fc2287ad514e99 100644
--- a/llvm/include/llvm/SandboxIR/Pass.h
+++ b/llvm/include/llvm/SandboxIR/Pass.h
@@ -12,11 +12,23 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
-namespace llvm::sandboxir {
+namespace llvm {
+
+class ScalarEvolution;
+
+namespace sandboxir {
class Function;
class Region;
+class Analyses {
+ ScalarEvolution &SE;
+
+public:
+ Analyses(ScalarEvolution &SE) : SE(SE) {}
+ ScalarEvolution &getScalarEvolution() const { return SE; }
+};
+
/// The base class of a Sandbox IR Pass.
class Pass {
protected:
@@ -52,7 +64,7 @@ class FunctionPass : public Pass {
/// \p Name can't contain any spaces or start with '-'.
FunctionPass(StringRef Name) : Pass(Name) {}
/// \Returns true if it modifies \p F.
- virtual bool runOnFunction(Function &F) = 0;
+ virtual bool runOnFunction(Function &F, const Analyses &A) = 0;
};
/// A pass that runs on a sandbox::Region.
@@ -61,9 +73,10 @@ class RegionPass : public Pass {
/// \p Name can't contain any spaces or start with '-'.
RegionPass(StringRef Name) : Pass(Name) {}
/// \Returns true if it modifies \p R.
- virtual bool runOnRegion(Region &R) = 0;
+ virtual bool runOnRegion(Region &R, const Analyses &A) = 0;
};
-} // namespace llvm::sandboxir
+} // namespace sandboxir
+} // namespace llvm
#endif // LLVM_SANDBOXIR_PASS_H
diff --git a/llvm/include/llvm/SandboxIR/PassManager.h b/llvm/include/llvm/SandboxIR/PassManager.h
index e8221996bc8f04..77154cc7143454 100644
--- a/llvm/include/llvm/SandboxIR/PassManager.h
+++ b/llvm/include/llvm/SandboxIR/PassManager.h
@@ -208,7 +208,7 @@ class FunctionPassManager final
FunctionPassManager(StringRef Name, StringRef Pipeline,
CreatePassFunc CreatePass)
: PassManager(Name, Pipeline, CreatePass) {}
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
};
class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
@@ -217,7 +217,7 @@ class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
RegionPassManager(StringRef Name, StringRef Pipeline,
CreatePassFunc CreatePass)
: PassManager(Name, Pipeline, CreatePass) {}
- bool runOnRegion(Region &R) final;
+ bool runOnRegion(Region &R, const Analyses &A) final;
};
} // namespace llvm::sandboxir
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
index 5cd47efd6b3462..2b0b3f8192c048 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
@@ -33,7 +33,7 @@ class BottomUpVec final : public FunctionPass {
public:
BottomUpVec(StringRef Pipeline);
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
void printPipeline(raw_ostream &OS) const final {
OS << getName() << "\n";
RPM.printPipeline(OS);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
index 75b9f42520156c..1025379770bac0 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h
@@ -11,7 +11,7 @@ class Region;
class NullPass final : public RegionPass {
public:
NullPass() : RegionPass("null") {}
- bool runOnRegion(Region &R) final { return false; }
+ bool runOnRegion(Region &R, const Analyses &A) final { return false; }
};
} // namespace llvm::sandboxir
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
index 9d88bc82803847..cd11d4c1489268 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
@@ -12,7 +12,7 @@ namespace llvm::sandboxir {
class PrintInstructionCount final : public RegionPass {
public:
PrintInstructionCount() : RegionPass("null") {}
- bool runOnRegion(Region &R) final {
+ bool runOnRegion(Region &R, const Analyses &A) final {
outs() << "InstructionCount: " << std::distance(R.begin(), R.end()) << "\n";
return false;
}
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
index 3d82a61c90153a..3d738ac8917eff 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
@@ -26,7 +26,7 @@ class RegionsFromMetadata final : public FunctionPass {
public:
RegionsFromMetadata(StringRef Pipeline);
- bool runOnFunction(Function &F) final;
+ bool runOnFunction(Function &F, const Analyses &A) final;
void printPipeline(raw_ostream &OS) const final {
OS << getName() << "\n";
RPM.printPipeline(OS);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
index b83744cf9e6cb6..03867df3d98084 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
@@ -10,6 +10,7 @@
#include <memory>
+#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/IR/PassManager.h"
#include "llvm/SandboxIR/PassManager.h"
@@ -19,6 +20,7 @@ class TargetTransformInfo;
class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
TargetTransformInfo *TTI = nullptr;
+ ScalarEvolution *SE = nullptr;
// A pipeline of SandboxIR function passes run by the vectorizer.
sandboxir::FunctionPassManager FPM;
diff --git a/llvm/lib/SandboxIR/PassManager.cpp b/llvm/lib/SandboxIR/PassManager.cpp
index 3a1cfa1d367a2a..aaa49e0f6912b6 100644
--- a/llvm/lib/SandboxIR/PassManager.cpp
+++ b/llvm/lib/SandboxIR/PassManager.cpp
@@ -10,20 +10,20 @@
namespace llvm::sandboxir {
-bool FunctionPassManager::runOnFunction(Function &F) {
+bool FunctionPassManager::runOnFunction(Function &F, const Analyses &A) {
bool Change = false;
for (auto &Pass : Passes) {
- Change |= Pass->runOnFunction(F);
+ Change |= Pass->runOnFunction(F, A);
// TODO: run the verifier.
}
// TODO: Check ChangeAll against hashes before/after.
return Change;
}
-bool RegionPassManager::runOnRegion(Region &R) {
+bool RegionPassManager::runOnRegion(Region &R, const Analyses &A) {
bool Change = false;
for (auto &Pass : Passes) {
- Change |= Pass->runOnRegion(R);
+ Change |= Pass->runOnRegion(R, A);
// TODO: run the verifier.
}
// TODO: Check ChangeAll against hashes before/after.
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
index ede41cd661b559..66d631edfc4076 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
@@ -59,7 +59,7 @@ void BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl) {
void BottomUpVec::tryVectorize(ArrayRef<Value *> Bndl) { vectorizeRec(Bndl); }
-bool BottomUpVec::runOnFunction(Function &F) {
+bool BottomUpVec::runOnFunction(Function &F, const Analyses &A) {
Change = false;
// TODO: Start from innermost BBs first
for (auto &BB : F) {
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
index 5887d5e8bc2683..8e3f5b77429c5a 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.cpp
@@ -17,11 +17,11 @@ RegionsFromMetadata::RegionsFromMetadata(StringRef Pipeline)
: FunctionPass("regions-from-metadata"),
RPM("rpm", Pipeline, SandboxVectorizerPassBuilder::createRegionPass) {}
-bool RegionsFromMetadata::runOnFunction(Function &F) {
+bool RegionsFromMetadata::runOnFunction(Function &F, const Analyses &A) {
SmallVector<std::unique_ptr<sandboxir::Region>> Regions =
sandboxir::Region::createRegionsFromMD(F);
for (auto &R : Regions) {
- RPM.runOnRegion(*R);
+ RPM.runOnRegion(*R, A);
}
return false;
}
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
index c68f9482e337dd..96d825ed852fb2 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp
@@ -51,6 +51,7 @@ SandboxVectorizerPass::~SandboxVectorizerPass() = default;
PreservedAnalyses SandboxVectorizerPass::run(Function &F,
FunctionAnalysisManager &AM) {
TTI = &AM.getResult<TargetIRAnalysis>(F);
+ SE = &AM.getResult<ScalarEvolutionAnalysis>(F);
bool Changed = runImpl(F);
if (!Changed)
@@ -82,5 +83,6 @@ bool SandboxVectorizerPass::runImpl(Function &LLVMF) {
// Create SandboxIR for LLVMF and run BottomUpVec on it.
sandboxir::Context Ctx(LLVMF.getContext());
sandboxir::Function &F = *Ctx.createFunction(&LLVMF);
- return FPM.runOnFunction(F);
+ sandboxir::Analyses A(*SE);
+ return FPM.runOnFunction(F, A);
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, as long as passes make sure that everything in Analyses is never invalidated
|
||
public: | ||
/// Used by unittests. | ||
Analyses() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this API is a bit dangerous to expose. Perhaps
class Analyses {
private:
Analyses() = default;
public:
Analyses(ScalarEvolution&) : SE(&SE) {}
static Analyses emptyForTesting() { return Analyses(); }
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
The Analyses class provides a way to pass around commonly used Analyses to SandboxIR passes throught `runOnFunction()` and `runOnRegion()` functions.
The Analyses class provides a way to pass around commonly used Analyses to SandboxIR passes throught `runOnFunction()` and `runOnRegion()` functions.
The Analyses class provides a way to pass around commonly used Analyses to SandboxIR passes throught
runOnFunction()
andrunOnRegion()
functions.