-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[Scalar] Use LLVMContext::MD_mem_parallel_loop_access directly (NFC) #69549
[Scalar] Use LLVMContext::MD_mem_parallel_loop_access directly (NFC) #69549
Conversation
This patch "constant propagates" LLVMContext::MD_mem_parallel_loop_access into wherever ParallelLoopAccessMDKind is used.
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesThis patch "constant propagates" Full diff: https://github.com/llvm/llvm-project/pull/69549.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 111c477337535f0..f5e480ae36bf42c 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -282,12 +282,10 @@ T getWithDefaultOverride(const cl::opt<T> &ClOption,
class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
public:
- ScalarizerVisitor(unsigned ParallelLoopAccessMDKind, DominatorTree *DT,
- ScalarizerPassOptions Options)
- : ParallelLoopAccessMDKind(ParallelLoopAccessMDKind), DT(DT),
- ScalarizeVariableInsertExtract(
- getWithDefaultOverride(ClScalarizeVariableInsertExtract,
- Options.ScalarizeVariableInsertExtract)),
+ ScalarizerVisitor(DominatorTree *DT, ScalarizerPassOptions Options)
+ : DT(DT), ScalarizeVariableInsertExtract(getWithDefaultOverride(
+ ClScalarizeVariableInsertExtract,
+ Options.ScalarizeVariableInsertExtract)),
ScalarizeLoadStore(getWithDefaultOverride(ClScalarizeLoadStore,
Options.ScalarizeLoadStore)),
ScalarizeMinBits(getWithDefaultOverride(ClScalarizeMinBits,
@@ -337,8 +335,6 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
SmallVector<WeakTrackingVH, 32> PotentiallyDeadInstrs;
- unsigned ParallelLoopAccessMDKind;
-
DominatorTree *DT;
const bool ScalarizeVariableInsertExtract;
@@ -448,8 +444,7 @@ bool ScalarizerLegacyPass::runOnFunction(Function &F) {
return false;
DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- ScalarizerVisitor Impl(LLVMContext::MD_mem_parallel_loop_access, DT,
- ScalarizerPassOptions());
+ ScalarizerVisitor Impl(DT, ScalarizerPassOptions());
return Impl.visit(F);
}
@@ -556,7 +551,7 @@ bool ScalarizerVisitor::canTransferMetadata(unsigned Tag) {
|| Tag == LLVMContext::MD_invariant_load
|| Tag == LLVMContext::MD_alias_scope
|| Tag == LLVMContext::MD_noalias
- || Tag == ParallelLoopAccessMDKind
+ || Tag == LLVMContext::MD_mem_parallel_loop_access
|| Tag == LLVMContext::MD_access_group);
}
@@ -1253,7 +1248,7 @@ bool ScalarizerVisitor::finish() {
PreservedAnalyses ScalarizerPass::run(Function &F, FunctionAnalysisManager &AM) {
DominatorTree *DT = &AM.getResult<DominatorTreeAnalysis>(F);
- ScalarizerVisitor Impl(LLVMContext::MD_mem_parallel_loop_access, DT, Options);
+ ScalarizerVisitor Impl(DT, Options);
bool Changed = Impl.visit(F);
PreservedAnalyses PA;
PA.preserve<DominatorTreeAnalysis>();
|
You can test this locally with the following command:git-clang-format --diff ab301d833a207c717adff9612a4e58fe963e6ff0 f0372d03e5d9c9968c3272e6cb1438412ba8c72a -- llvm/lib/Transforms/Scalar/Scalarizer.cpp View the diff from clang-format here.diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index f5e480ae3..b2461607a 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -545,14 +545,13 @@ void ScalarizerVisitor::replaceUses(Instruction *Op, Value *CV) {
// Return true if it is safe to transfer the given metadata tag from
// vector to scalar instructions.
bool ScalarizerVisitor::canTransferMetadata(unsigned Tag) {
- return (Tag == LLVMContext::MD_tbaa
- || Tag == LLVMContext::MD_fpmath
- || Tag == LLVMContext::MD_tbaa_struct
- || Tag == LLVMContext::MD_invariant_load
- || Tag == LLVMContext::MD_alias_scope
- || Tag == LLVMContext::MD_noalias
- || Tag == LLVMContext::MD_mem_parallel_loop_access
- || Tag == LLVMContext::MD_access_group);
+ return (Tag == LLVMContext::MD_tbaa || Tag == LLVMContext::MD_fpmath ||
+ Tag == LLVMContext::MD_tbaa_struct ||
+ Tag == LLVMContext::MD_invariant_load ||
+ Tag == LLVMContext::MD_alias_scope ||
+ Tag == LLVMContext::MD_noalias ||
+ Tag == LLVMContext::MD_mem_parallel_loop_access ||
+ Tag == LLVMContext::MD_access_group);
}
// Transfer metadata from Op to the instructions in CV if it is known
|
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.
LGTM. Seems to date back to the time when getMDKindID("llvm.mem.parallel_loop_access")
was used to fetch this.
This patch "constant propagates"
LLVMContext::MD_mem_parallel_loop_access into wherever
ParallelLoopAccessMDKind is used.