-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Instrumentation] Support MachineFunction
in OptNoneInstrumentation
#115471
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-selectiondag @llvm/pr-subscribers-llvm-regalloc Author: None (paperchalice) ChangesSupport Full diff: https://github.com/llvm/llvm-project/pull/115471.diff 15 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/FinalizeISel.h b/llvm/include/llvm/CodeGen/FinalizeISel.h
index 117140417e2c2c..b2c28e330126fc 100644
--- a/llvm/include/llvm/CodeGen/FinalizeISel.h
+++ b/llvm/include/llvm/CodeGen/FinalizeISel.h
@@ -16,6 +16,7 @@ namespace llvm {
class FinalizeISelPass : public PassInfoMixin<FinalizeISelPass> {
public:
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
index bf5225d3e99a54..b02667d5c6699d 100644
--- a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
+++ b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
@@ -17,6 +17,7 @@ class LocalStackSlotAllocationPass
: public PassInfoMixin<LocalStackSlotAllocationPass> {
public:
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MIRPrinter.h b/llvm/include/llvm/CodeGen/MIRPrinter.h
index 85bd674c56a60c..37d9f8ff502db0 100644
--- a/llvm/include/llvm/CodeGen/MIRPrinter.h
+++ b/llvm/include/llvm/CodeGen/MIRPrinter.h
@@ -31,6 +31,7 @@ class PrintMIRPreparePass : public PassInfoMixin<PrintMIRPreparePass> {
public:
PrintMIRPreparePass(raw_ostream &OS = errs()) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
class PrintMIRPass : public PassInfoMixin<PrintMIRPass> {
@@ -40,6 +41,7 @@ class PrintMIRPass : public PassInfoMixin<PrintMIRPass> {
PrintMIRPass(raw_ostream &OS = errs()) : OS(OS) {}
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
/// Print LLVM IR using the MIR serialization format to the given output stream.
diff --git a/llvm/include/llvm/CodeGen/MachineVerifier.h b/llvm/include/llvm/CodeGen/MachineVerifier.h
index bfd0681fb79545..9d82b5417c927e 100644
--- a/llvm/include/llvm/CodeGen/MachineVerifier.h
+++ b/llvm/include/llvm/CodeGen/MachineVerifier.h
@@ -21,6 +21,7 @@ class MachineVerifierPass : public PassInfoMixin<MachineVerifierPass> {
: Banner(Banner) {}
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PHIElimination.h b/llvm/include/llvm/CodeGen/PHIElimination.h
index 3a1a4c5c6133f8..d3c884b8413c7a 100644
--- a/llvm/include/llvm/CodeGen/PHIElimination.h
+++ b/llvm/include/llvm/CodeGen/PHIElimination.h
@@ -17,6 +17,7 @@ class PHIEliminationPass : public PassInfoMixin<PHIEliminationPass> {
public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index 440264a06ae89e..b2ca9e10bf4647 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -50,6 +50,8 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName);
+
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 32b2ea48179f47..f99ec4651009a0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -551,6 +551,7 @@ class SelectionDAGISelPass : public PassInfoMixin<SelectionDAGISelPass> {
public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
}
diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp
index 3e73995846176e..b95516f616e0f1 100644
--- a/llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -1119,9 +1119,6 @@ bool EarlyIfConverter::run(MachineFunction &MF) {
PreservedAnalyses
EarlyIfConverterPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
MachineDominatorTree &MDT = MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
MachineLoopInfo &LI = MFAM.getResult<MachineLoopAnalysis>(MF);
MachineTraceMetrics &MTM = MFAM.getResult<MachineTraceMetricsAnalysis>(MF);
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index 8e9fcccff77645..0a547050e91a8a 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -957,9 +957,6 @@ PreservedAnalyses MachineCSEPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
MFPropsModifier _(*this, MF);
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
MachineDominatorTree &MDT = MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
MachineBlockFrequencyInfo &MBFI =
MFAM.getResult<MachineBlockFrequencyAnalysis>(MF);
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 7ea07862b839d0..005dc42fe8dec8 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1763,9 +1763,6 @@ bool MachineLICMImpl::isTgtHotterThanSrc(MachineBasicBlock *SrcBlock,
template <typename DerivedT, bool PreRegAlloc>
PreservedAnalyses MachineLICMBasePass<DerivedT, PreRegAlloc>::run(
MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
bool Changed = MachineLICMImpl(PreRegAlloc, nullptr, &MFAM).run(MF);
if (!Changed)
return PreservedAnalyses::all();
diff --git a/llvm/lib/CodeGen/OptimizePHIs.cpp b/llvm/lib/CodeGen/OptimizePHIs.cpp
index cccc368e56e40d..569b6b2f769c00 100644
--- a/llvm/lib/CodeGen/OptimizePHIs.cpp
+++ b/llvm/lib/CodeGen/OptimizePHIs.cpp
@@ -81,9 +81,6 @@ INITIALIZE_PASS(OptimizePHIsLegacy, DEBUG_TYPE,
PreservedAnalyses OptimizePHIsPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
OptimizePHIs OP;
if (!OP.run(MF))
return PreservedAnalyses::all();
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 0be31d5db11ae2..0305bdce26f731 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -1193,9 +1193,6 @@ bool StackColoringLegacy::runOnMachineFunction(MachineFunction &MF) {
PreservedAnalyses StackColoringPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
StackColoring SC(&MFAM.getResult<SlotIndexesAnalysis>(MF));
if (SC.run(MF))
return PreservedAnalyses::none();
diff --git a/llvm/lib/CodeGen/TailDuplication.cpp b/llvm/lib/CodeGen/TailDuplication.cpp
index b698ca675b65e2..a50cdcfa7cc60e 100644
--- a/llvm/lib/CodeGen/TailDuplication.cpp
+++ b/llvm/lib/CodeGen/TailDuplication.cpp
@@ -110,9 +110,6 @@ PreservedAnalyses TailDuplicatePassBase<DerivedT, PreRegAlloc>::run(
MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) {
MFPropsModifier _(static_cast<DerivedT &>(*this), MF);
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
auto *MBPI = &MFAM.getResult<MachineBranchProbabilityAnalysis>(MF);
auto *PSI = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
.getCachedResult<ProfileSummaryAnalysis>(
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index d4866a025c1b48..5a3bf8884cd542 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -1048,14 +1048,16 @@ void OptNoneInstrumentation::registerCallbacks(
}
bool OptNoneInstrumentation::shouldRun(StringRef PassID, Any IR) {
- const auto *F = unwrapIR<Function>(IR);
- if (!F) {
- if (const auto *L = unwrapIR<Loop>(IR))
- F = L->getHeader()->getParent();
- }
- bool ShouldRun = !(F && F->hasOptNone());
+ bool ShouldRun = true;
+ if (const auto *F = unwrapIR<Function>(IR))
+ ShouldRun = !F->hasOptNone();
+ else if (const auto *L = unwrapIR<Loop>(IR))
+ ShouldRun = !L->getHeader()->getParent()->hasOptNone();
+ else if (const auto *MF = unwrapIR<MachineFunction>(IR))
+ ShouldRun = !MF->getFunction().hasOptNone();
+
if (!ShouldRun && DebugLogging) {
- errs() << "Skipping pass " << PassID << " on " << F->getName()
+ errs() << "Skipping pass " << PassID << " on " << getIRName(IR)
<< " due to optnone attribute\n";
}
return ShouldRun;
diff --git a/llvm/test/CodeGen/X86/optnone.mir b/llvm/test/CodeGen/X86/optnone.mir
new file mode 100644
index 00000000000000..ae572cd6c3a50e
--- /dev/null
+++ b/llvm/test/CodeGen/X86/optnone.mir
@@ -0,0 +1,20 @@
+# RUN: llc -passes=machine-cse -debug-pass-manager %s -o - 2>&1 | FileCheck %s
+
+# CHECK: Skipping pass MachineCSEPass on test_optnone due to optnone attribute
+# CHECK: Running pass: MachineCSEPass on test_opt
+--- |
+ define void @test_optnone() noinline optnone { ret void }
+ define void @test_opt() { ret void }
+...
+---
+name: test_optnone
+body: |
+ bb.0:
+ RET64
+...
+---
+name: test_opt
+body: |
+ bb.0:
+ RET64
+...
|
@llvm/pr-subscribers-backend-x86 Author: None (paperchalice) ChangesSupport Full diff: https://github.com/llvm/llvm-project/pull/115471.diff 15 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/FinalizeISel.h b/llvm/include/llvm/CodeGen/FinalizeISel.h
index 117140417e2c2c..b2c28e330126fc 100644
--- a/llvm/include/llvm/CodeGen/FinalizeISel.h
+++ b/llvm/include/llvm/CodeGen/FinalizeISel.h
@@ -16,6 +16,7 @@ namespace llvm {
class FinalizeISelPass : public PassInfoMixin<FinalizeISelPass> {
public:
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
index bf5225d3e99a54..b02667d5c6699d 100644
--- a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
+++ b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
@@ -17,6 +17,7 @@ class LocalStackSlotAllocationPass
: public PassInfoMixin<LocalStackSlotAllocationPass> {
public:
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MIRPrinter.h b/llvm/include/llvm/CodeGen/MIRPrinter.h
index 85bd674c56a60c..37d9f8ff502db0 100644
--- a/llvm/include/llvm/CodeGen/MIRPrinter.h
+++ b/llvm/include/llvm/CodeGen/MIRPrinter.h
@@ -31,6 +31,7 @@ class PrintMIRPreparePass : public PassInfoMixin<PrintMIRPreparePass> {
public:
PrintMIRPreparePass(raw_ostream &OS = errs()) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
class PrintMIRPass : public PassInfoMixin<PrintMIRPass> {
@@ -40,6 +41,7 @@ class PrintMIRPass : public PassInfoMixin<PrintMIRPass> {
PrintMIRPass(raw_ostream &OS = errs()) : OS(OS) {}
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
/// Print LLVM IR using the MIR serialization format to the given output stream.
diff --git a/llvm/include/llvm/CodeGen/MachineVerifier.h b/llvm/include/llvm/CodeGen/MachineVerifier.h
index bfd0681fb79545..9d82b5417c927e 100644
--- a/llvm/include/llvm/CodeGen/MachineVerifier.h
+++ b/llvm/include/llvm/CodeGen/MachineVerifier.h
@@ -21,6 +21,7 @@ class MachineVerifierPass : public PassInfoMixin<MachineVerifierPass> {
: Banner(Banner) {}
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PHIElimination.h b/llvm/include/llvm/CodeGen/PHIElimination.h
index 3a1a4c5c6133f8..d3c884b8413c7a 100644
--- a/llvm/include/llvm/CodeGen/PHIElimination.h
+++ b/llvm/include/llvm/CodeGen/PHIElimination.h
@@ -17,6 +17,7 @@ class PHIEliminationPass : public PassInfoMixin<PHIEliminationPass> {
public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index 440264a06ae89e..b2ca9e10bf4647 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -50,6 +50,8 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName);
+
+ static bool isRequired() { return true; }
};
} // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 32b2ea48179f47..f99ec4651009a0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -551,6 +551,7 @@ class SelectionDAGISelPass : public PassInfoMixin<SelectionDAGISelPass> {
public:
PreservedAnalyses run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM);
+ static bool isRequired() { return true; }
};
}
diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp
index 3e73995846176e..b95516f616e0f1 100644
--- a/llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -1119,9 +1119,6 @@ bool EarlyIfConverter::run(MachineFunction &MF) {
PreservedAnalyses
EarlyIfConverterPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
MachineDominatorTree &MDT = MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
MachineLoopInfo &LI = MFAM.getResult<MachineLoopAnalysis>(MF);
MachineTraceMetrics &MTM = MFAM.getResult<MachineTraceMetricsAnalysis>(MF);
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index 8e9fcccff77645..0a547050e91a8a 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -957,9 +957,6 @@ PreservedAnalyses MachineCSEPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
MFPropsModifier _(*this, MF);
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
MachineDominatorTree &MDT = MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
MachineBlockFrequencyInfo &MBFI =
MFAM.getResult<MachineBlockFrequencyAnalysis>(MF);
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 7ea07862b839d0..005dc42fe8dec8 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1763,9 +1763,6 @@ bool MachineLICMImpl::isTgtHotterThanSrc(MachineBasicBlock *SrcBlock,
template <typename DerivedT, bool PreRegAlloc>
PreservedAnalyses MachineLICMBasePass<DerivedT, PreRegAlloc>::run(
MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
bool Changed = MachineLICMImpl(PreRegAlloc, nullptr, &MFAM).run(MF);
if (!Changed)
return PreservedAnalyses::all();
diff --git a/llvm/lib/CodeGen/OptimizePHIs.cpp b/llvm/lib/CodeGen/OptimizePHIs.cpp
index cccc368e56e40d..569b6b2f769c00 100644
--- a/llvm/lib/CodeGen/OptimizePHIs.cpp
+++ b/llvm/lib/CodeGen/OptimizePHIs.cpp
@@ -81,9 +81,6 @@ INITIALIZE_PASS(OptimizePHIsLegacy, DEBUG_TYPE,
PreservedAnalyses OptimizePHIsPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
OptimizePHIs OP;
if (!OP.run(MF))
return PreservedAnalyses::all();
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 0be31d5db11ae2..0305bdce26f731 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -1193,9 +1193,6 @@ bool StackColoringLegacy::runOnMachineFunction(MachineFunction &MF) {
PreservedAnalyses StackColoringPass::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
StackColoring SC(&MFAM.getResult<SlotIndexesAnalysis>(MF));
if (SC.run(MF))
return PreservedAnalyses::none();
diff --git a/llvm/lib/CodeGen/TailDuplication.cpp b/llvm/lib/CodeGen/TailDuplication.cpp
index b698ca675b65e2..a50cdcfa7cc60e 100644
--- a/llvm/lib/CodeGen/TailDuplication.cpp
+++ b/llvm/lib/CodeGen/TailDuplication.cpp
@@ -110,9 +110,6 @@ PreservedAnalyses TailDuplicatePassBase<DerivedT, PreRegAlloc>::run(
MachineFunction &MF, MachineFunctionAnalysisManager &MFAM) {
MFPropsModifier _(static_cast<DerivedT &>(*this), MF);
- if (MF.getFunction().hasOptNone())
- return PreservedAnalyses::all();
-
auto *MBPI = &MFAM.getResult<MachineBranchProbabilityAnalysis>(MF);
auto *PSI = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
.getCachedResult<ProfileSummaryAnalysis>(
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index d4866a025c1b48..5a3bf8884cd542 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -1048,14 +1048,16 @@ void OptNoneInstrumentation::registerCallbacks(
}
bool OptNoneInstrumentation::shouldRun(StringRef PassID, Any IR) {
- const auto *F = unwrapIR<Function>(IR);
- if (!F) {
- if (const auto *L = unwrapIR<Loop>(IR))
- F = L->getHeader()->getParent();
- }
- bool ShouldRun = !(F && F->hasOptNone());
+ bool ShouldRun = true;
+ if (const auto *F = unwrapIR<Function>(IR))
+ ShouldRun = !F->hasOptNone();
+ else if (const auto *L = unwrapIR<Loop>(IR))
+ ShouldRun = !L->getHeader()->getParent()->hasOptNone();
+ else if (const auto *MF = unwrapIR<MachineFunction>(IR))
+ ShouldRun = !MF->getFunction().hasOptNone();
+
if (!ShouldRun && DebugLogging) {
- errs() << "Skipping pass " << PassID << " on " << F->getName()
+ errs() << "Skipping pass " << PassID << " on " << getIRName(IR)
<< " due to optnone attribute\n";
}
return ShouldRun;
diff --git a/llvm/test/CodeGen/X86/optnone.mir b/llvm/test/CodeGen/X86/optnone.mir
new file mode 100644
index 00000000000000..ae572cd6c3a50e
--- /dev/null
+++ b/llvm/test/CodeGen/X86/optnone.mir
@@ -0,0 +1,20 @@
+# RUN: llc -passes=machine-cse -debug-pass-manager %s -o - 2>&1 | FileCheck %s
+
+# CHECK: Skipping pass MachineCSEPass on test_optnone due to optnone attribute
+# CHECK: Running pass: MachineCSEPass on test_opt
+--- |
+ define void @test_optnone() noinline optnone { ret void }
+ define void @test_opt() { ret void }
+...
+---
+name: test_optnone
+body: |
+ bb.0:
+ RET64
+...
+---
+name: test_opt
+body: |
+ bb.0:
+ RET64
+...
|
@@ -40,6 +41,7 @@ class PrintMIRPass : public PassInfoMixin<PrintMIRPass> { | |||
PrintMIRPass(raw_ostream &OS = errs()) : OS(OS) {} | |||
PreservedAnalyses run(MachineFunction &MF, | |||
MachineFunctionAnalysisManager &MFAM); | |||
static bool isRequired() { return true; } |
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.
So this is essentially a concept? This needs something to document it in the base class?
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
for the isRequired
concept, @chandlerc had the idea to have a RequiredPassInfoMixin
/OptionalPassInfoMixin
which had static constexpr bool isRequired = true/false
that passes could inherit from and error out if there was no isRequired
on the pass. I like this a lot as opposed to having a default
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/8116 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/8114 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/155/builds/3993 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/6016 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/5331 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/3326 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/17/builds/3798 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/4367 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/125/builds/3385 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/3056 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/39/builds/2724 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/41/builds/3305 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/3445 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/3439 Here is the relevant piece of the build log for the reference
|
…n` (llvm#115471) Support `MachineFunction` in `OptNoneInstrumentation`, also add `isRequired` to all necessary passes.
Add triple to indicate this is x86 test.
Support
MachineFunction
inOptNoneInstrumentation
, also addisRequired
to all necessary passes.