[PATCH] Add a callback to FunctionPass to enable skipping execution on a per-function basis
Chandler Carruth
chandlerc at gmail.com
Fri Jun 5 12:31:48 PDT 2015
Thanks for prodding me Eric, I didn't realize you all actuall ywanted me to look at part of this.
================
Comment at: include/llvm/Pass.h:313
@@ -311,1 +312,3 @@
+ typedef std::function<bool(const Function &)> PredicateFtorTy;
+
----------------
I would much rather not have a typedef here. The typedef is in a large part obscuring what is happening. By saying "std::function<bool(const Function &)>" in the signature where this is used it's a lot clearer what signature of predicate should be used.
================
Comment at: lib/CodeGen/Passes.cpp:295-312
@@ -294,2 +294,20 @@
}
+
+ // Add the passes after the pass P if there is any.
+ for (SmallVectorImpl<std::pair<AnalysisID, IdentifyingPassPtr> >::iterator
+ I = Impl->InsertedPasses.begin(),
+ E = Impl->InsertedPasses.end();
+ I != E; ++I) {
+ if ((*I).first == PassID) {
+ assert((*I).second.isValid() && "Illegal Pass ID!");
+ Pass *NP;
+ if ((*I).second.isInstance())
+ NP = (*I).second.getInstance();
+ else {
+ NP = Pass::createPass((*I).second.getID());
+ assert(NP && "Pass ID not registered");
+ }
+ addPass(NP, false, false);
+ }
+ }
} else {
----------------
ahatanak wrote:
> echristo wrote:
> > I'm probably missing something, but why move this code?
> Two make-check tests (CodeGen/ARM/ifcvt-branch-weight-bug.ll and ifcvt-branch-weight.ll) fail without this change.
>
> Currently, this code is executed when print-machineinstrs pass has to be added to the pipeline and it is executed only when the overloaded version of addPass that takes AnalysisID is called. Since this patch changes ARMPassConfig::addPreSched2 to use the version of addPass that takes Pass* to add the if-converter pass, I had to move this code to addPass(Pass*) so that it gets executed when either of the overloaded functions is called.
This is clearly a correct change, but please make it in a separate commit. This code should never have lived in the AnalyisID overload when the point of it (at least the only used point I can find) is to insert machine instr printing passes after each other pass added in the backend.
http://reviews.llvm.org/D8717
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list