-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SandboxVec] Add pass to create Regions from metadata. Generalize SandboxVec pass pipelines. #112288
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
[SandboxVec] Add pass to create Regions from metadata. Generalize SandboxVec pass pipelines. #112288
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_PRINTINSTRUCTIONCOUNT_H | ||
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_PRINTINSTRUCTIONCOUNT_H | ||
|
||
#include "llvm/SandboxIR/Pass.h" | ||
#include "llvm/SandboxIR/Region.h" | ||
|
||
namespace llvm::sandboxir { | ||
|
||
/// A Region pass that prints the instruction count for the region to stdout. | ||
/// Used to test -sbvec-passes while we don't have any actual optimization | ||
/// passes. | ||
class PrintInstructionCount final : public RegionPass { | ||
public: | ||
PrintInstructionCount() : RegionPass("null") {} | ||
bool runOnRegion(Region &R) final { | ||
outs() << "InstructionCount: " << std::distance(R.begin(), R.end()) << "\n"; | ||
return false; | ||
} | ||
}; | ||
|
||
} // namespace llvm::sandboxir | ||
|
||
#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_PRINTINSTRUCTIONCOUNTPASS_H |
38 changes: 38 additions & 0 deletions
38
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//===- RegionsFromMetadata.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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// A SandboxIR function pass that builds regions from IR metadata and then runs | ||
// a pipeline of region passes on them. This is useful to test region passes in | ||
// isolation without relying on the output of the bottom-up vectorizer. | ||
// | ||
|
||
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_REGIONSFROMMETADATA_H | ||
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_REGIONSFROMMETADATA_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/SandboxIR/Pass.h" | ||
#include "llvm/SandboxIR/PassManager.h" | ||
|
||
namespace llvm::sandboxir { | ||
|
||
class RegionsFromMetadata final : public FunctionPass { | ||
// The PM containing the pipeline of region passes. | ||
RegionPassManager RPM; | ||
|
||
public: | ||
RegionsFromMetadata(StringRef Pipeline); | ||
bool runOnFunction(Function &F) final; | ||
void printPipeline(raw_ostream &OS) const final { | ||
OS << getName() << "\n"; | ||
RPM.printPipeline(OS); | ||
} | ||
}; | ||
|
||
} // namespace llvm::sandboxir | ||
|
||
#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_REGIONSFROMMETADATA_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//===- SandboxVectorizerPassBuilder.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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Utility functions so passes with sub-pipelines can create SandboxVectorizer | ||
// passes without replicating the same logic in each pass. | ||
// | ||
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZERPASSBUILDER_H | ||
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZERPASSBUILDER_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
#include "llvm/SandboxIR/Pass.h" | ||
|
||
#include <memory> | ||
|
||
namespace llvm::sandboxir { | ||
|
||
class SandboxVectorizerPassBuilder { | ||
public: | ||
static std::unique_ptr<FunctionPass> createFunctionPass(StringRef Name, | ||
StringRef Args); | ||
static std::unique_ptr<RegionPass> createRegionPass(StringRef Name, | ||
StringRef Args); | ||
}; | ||
|
||
} // namespace llvm::sandboxir | ||
|
||
#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SANDBOXVECTORIZERPASSBUILDER_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't this be guarde by
#ifndef NDEBUG
?Uh oh!
There was an error while loading. Please reload this page.
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.
That's the code that implements the
-sbvec-print-pass-pipeline
flag. And it wasn't guarded before. Do we want the flag to only work in debug builds? If so, should we guard the flag as well? (also the tests that rely on printing the pass pipeline will become unsupported in release builds) I think those questions are out of scope for this PR.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.
Ah, it's because of the tests, makes sense.