[llvm] 6e56c35 - [SpeculativeExecution] Add only-if-divergent-target pass option
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 02:49:46 PST 2023
Author: Nikita Popov
Date: 2023-11-07T11:49:37+01:00
New Revision: 6e56c35d1959295289734baf8924d477f770d6f8
URL: https://github.com/llvm/llvm-project/commit/6e56c35d1959295289734baf8924d477f770d6f8
DIFF: https://github.com/llvm/llvm-project/commit/6e56c35d1959295289734baf8924d477f770d6f8.diff
LOG: [SpeculativeExecution] Add only-if-divergent-target pass option
The optimization pipeline enables this option, but it was not
preserved in -print-pipeline-passes output.
Added:
Modified:
llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
llvm/test/CodeGen/NVPTX/speculative-execution-divergent-target.ll
llvm/test/Other/new-pm-print-pipeline.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h b/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
index 0ec2a395f875e74..d17186682fb8f05 100644
--- a/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
+++ b/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
@@ -73,6 +73,9 @@ class SpeculativeExecutionPass
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+ void printPipeline(raw_ostream &OS,
+ function_ref<StringRef(StringRef)> MapClassName2PassName);
+
// Glue for old PM
bool runImpl(Function &F, TargetTransformInfo *TTI);
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 0d7cac19d44c3a8..dd9d799f9d55dcc 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1082,6 +1082,11 @@ Expected<bool> parseMemorySSAPrinterPassOptions(StringRef Params) {
"MemorySSAPrinterPass");
}
+Expected<bool> parseSpeculativeExecutionPassOptions(StringRef Params) {
+ return parseSinglePassOption(Params, "only-if-divergent-target",
+ "SpeculativeExecutionPass");
+}
+
Expected<std::string> parseMemProfUsePassOptions(StringRef Params) {
std::string Result;
while (!Params.empty()) {
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index eb51ccef68c827d..2067fc473b522db 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -424,7 +424,6 @@ FUNCTION_PASS("sccp", SCCPPass())
FUNCTION_PASS("sink", SinkingPass())
FUNCTION_PASS("slp-vectorizer", SLPVectorizerPass())
FUNCTION_PASS("slsr", StraightLineStrengthReducePass())
-FUNCTION_PASS("speculative-execution", SpeculativeExecutionPass())
FUNCTION_PASS("strip-gc-relocates", StripGCRelocates())
FUNCTION_PASS("structurizecfg", StructurizeCFGPass())
FUNCTION_PASS("tailcallelim", TailCallElimPass())
@@ -588,6 +587,13 @@ FUNCTION_PASS_WITH_PARAMS("print<memoryssa>",
},
parseMemorySSAPrinterPassOptions,
"no-ensure-optimized-uses")
+FUNCTION_PASS_WITH_PARAMS("speculative-execution",
+ "SpeculativeExecutionPass",
+ [](bool OnlyIfDivergentTarget) {
+ return SpeculativeExecutionPass(OnlyIfDivergentTarget);
+ },
+ parseSpeculativeExecutionPassOptions,
+ "only-if-divergent-target")
#undef FUNCTION_PASS_WITH_PARAMS
#ifndef LOOPNEST_PASS
diff --git a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
index 4771624a19494de..7a5318d4404ca4b 100644
--- a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -346,4 +346,14 @@ PreservedAnalyses SpeculativeExecutionPass::run(Function &F,
PA.preserveSet<CFGAnalyses>();
return PA;
}
+
+void SpeculativeExecutionPass::printPipeline(
+ raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
+ static_cast<PassInfoMixin<SpeculativeExecutionPass> *>(this)->printPipeline(
+ OS, MapClassName2PassName);
+ OS << '<';
+ if (OnlyIfDivergentTarget)
+ OS << "only-if-divergent-target";
+ OS << '>';
+}
} // namespace llvm
diff --git a/llvm/test/CodeGen/NVPTX/speculative-execution-divergent-target.ll b/llvm/test/CodeGen/NVPTX/speculative-execution-divergent-target.ll
index f2be9235f447a15..1b652a46936c3eb 100644
--- a/llvm/test/CodeGen/NVPTX/speculative-execution-divergent-target.ll
+++ b/llvm/test/CodeGen/NVPTX/speculative-execution-divergent-target.ll
@@ -6,8 +6,13 @@
; RUN: opt < %s -S -mtriple=nvptx-nvidia-cuda -passes=speculative-execution \
; RUN: -spec-exec-only-if-divergent-target | \
; RUN: FileCheck --check-prefix=ON %s
+; RUN: opt < %s -S -mtriple=nvptx-nvidia-cuda \
+; RUN: -passes='speculative-execution<only-if-divergent-target>' | \
+; RUN: FileCheck --check-prefix=ON %s
; RUN: opt < %s -S -passes=speculative-execution -spec-exec-only-if-divergent-target | \
; RUN: FileCheck --check-prefix=OFF %s
+; RUN: opt < %s -S -passes='speculative-execution<only-if-divergent-target>' | \
+; RUN: FileCheck --check-prefix=OFF %s
; Hoist in if-then pattern.
define void @f() {
diff --git a/llvm/test/Other/new-pm-print-pipeline.ll b/llvm/test/Other/new-pm-print-pipeline.ll
index c9b06ac7e6e8e72..1bc0e95d10d811f 100644
--- a/llvm/test/Other/new-pm-print-pipeline.ll
+++ b/llvm/test/Other/new-pm-print-pipeline.ll
@@ -120,3 +120,6 @@
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='globaldce<vfe-linkage-unit-visibility>' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-35
; CHECK-35: globaldce<vfe-linkage-unit-visibility>
+
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='speculative-execution<only-if-divergent-target>' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-36
+; CHECK-36: function(speculative-execution<only-if-divergent-target>)
More information about the llvm-commits
mailing list