[PATCH] D55082: WIP: Try adding method to stop after specific runs of passes
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 15:17:03 PST 2018
arsenm created this revision.
arsenm added reviewers: MatzeB, qcolombet.
Herald added a subscriber: wdng.
Currently if you use -{start,stop}-{before,after}, it picks
the first instance with the matching pass name. If you run
the same pass multiple times, there's no way to distinguish them.
Allow specifying a run index with ,N to specify which you mean (e.g. -stop-before=si-shrink-instructions,1")
Just handle -stop-after before committing to how this should work
https://reviews.llvm.org/D55082
Files:
include/llvm/CodeGen/TargetPassConfig.h
lib/CodeGen/TargetPassConfig.cpp
Index: lib/CodeGen/TargetPassConfig.cpp
===================================================================
--- lib/CodeGen/TargetPassConfig.cpp
+++ lib/CodeGen/TargetPassConfig.cpp
@@ -345,11 +345,26 @@
return PI ? PI->getTypeInfo() : nullptr;
}
+static std::pair<StringRef, unsigned> getPassNameAndInstanceNum(StringRef PassName) {
+ StringRef Name, InstanceNumStr;
+ std::tie(Name, InstanceNumStr) = PassName.split(',');
+
+ unsigned InstanceNum;
+ if (InstanceNumStr.getAsInteger(10, InstanceNum))
+ return std::make_pair(Name, 0);
+
+ return std::make_pair(Name, InstanceNum);
+}
+
void TargetPassConfig::setStartStopPasses() {
+ StringRef StopAfterName;
+ std::tie(StopAfterName, StopAfterInstanceNum) = getPassNameAndInstanceNum(StopAfterOpt);
+
+
StartBefore = getPassIDFromName(StartBeforeOpt);
StartAfter = getPassIDFromName(StartAfterOpt);
StopBefore = getPassIDFromName(StopBeforeOpt);
- StopAfter = getPassIDFromName(StopAfterOpt);
+ StopAfter = getPassIDFromName(StopAfterName);
if (StartBefore && StartAfter)
report_fatal_error(Twine(StartBeforeOptName) + Twine(" and ") +
Twine(StartAfterOptName) + Twine(" specified!"));
@@ -518,8 +533,10 @@
} else {
delete P;
}
- if (StopAfter == PassID)
+
+ if (StopAfter == PassID && StopAfterCount++ == StopAfterInstanceNum4)
Stopped = true;
+
if (StartAfter == PassID)
Started = true;
if (Stopped && !Started)
Index: include/llvm/CodeGen/TargetPassConfig.h
===================================================================
--- include/llvm/CodeGen/TargetPassConfig.h
+++ include/llvm/CodeGen/TargetPassConfig.h
@@ -90,6 +90,10 @@
AnalysisID StartAfter = nullptr;
AnalysisID StopBefore = nullptr;
AnalysisID StopAfter = nullptr;
+
+ unsigned StopAfterInstanceNum = 0;
+ unsigned StopAfterCount = 0;
+
bool Started = true;
bool Stopped = false;
bool AddingMachinePasses = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55082.175974.patch
Type: text/x-patch
Size: 1944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181129/1487cc89/attachment.bin>
More information about the llvm-commits
mailing list