llvm.org GIT mirror llvm / 4c2adea
MIR: Add method to stop after specific runs of passes 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 wih ,N to specify which you mean. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348285 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 1 year, 11 months ago
5 changed file(s) with 110 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5858 runs just before the pass that we are trying to test:
5959
6060 ``llc -stop-after=machine-cp bug-trigger.ll > test.mir``
61
62 If the same pass is run multiple times, a run index can be included
63 after the name with a comma.
64
65 ``llc -stop-after=dead-mi-elimination,1 bug-trigger.ll > test.mir``
6166
6267 After generating the input MIR file, you'll have to add a run line that uses
6368 the ``-run-pass`` option to it. In order to test the post register allocation
8989 AnalysisID StartAfter = nullptr;
9090 AnalysisID StopBefore = nullptr;
9191 AnalysisID StopAfter = nullptr;
92
93 unsigned StartBeforeInstanceNum = 0;
94 unsigned StartBeforeCount = 0;
95
96 unsigned StartAfterInstanceNum = 0;
97 unsigned StartAfterCount = 0;
98
99 unsigned StopBeforeInstanceNum = 0;
100 unsigned StopBeforeCount = 0;
101
102 unsigned StopAfterInstanceNum = 0;
103 unsigned StopAfterCount = 0;
104
92105 bool Started = true;
93106 bool Stopped = false;
94107 bool AddingMachinePasses = false;
344344 return PI ? PI->getTypeInfo() : nullptr;
345345 }
346346
347 static std::pair
348 getPassNameAndInstanceNum(StringRef PassName) {
349 StringRef Name, InstanceNumStr;
350 std::tie(Name, InstanceNumStr) = PassName.split(',');
351
352 unsigned InstanceNum = 0;
353 if (!InstanceNumStr.empty() && InstanceNumStr.getAsInteger(10, InstanceNum))
354 report_fatal_error("invalid pass instance specifier " + PassName);
355
356 return std::make_pair(Name, InstanceNum);
357 }
358
347359 void TargetPassConfig::setStartStopPasses() {
348 StartBefore = getPassIDFromName(StartBeforeOpt);
349 StartAfter = getPassIDFromName(StartAfterOpt);
350 StopBefore = getPassIDFromName(StopBeforeOpt);
351 StopAfter = getPassIDFromName(StopAfterOpt);
360 StringRef StartBeforeName;
361 std::tie(StartBeforeName, StartBeforeInstanceNum) =
362 getPassNameAndInstanceNum(StartBeforeOpt);
363
364 StringRef StartAfterName;
365 std::tie(StartAfterName, StartAfterInstanceNum) =
366 getPassNameAndInstanceNum(StartAfterOpt);
367
368 StringRef StopBeforeName;
369 std::tie(StopBeforeName, StopBeforeInstanceNum)
370 = getPassNameAndInstanceNum(StopBeforeOpt);
371
372 StringRef StopAfterName;
373 std::tie(StopAfterName, StopAfterInstanceNum)
374 = getPassNameAndInstanceNum(StopAfterOpt);
375
376 StartBefore = getPassIDFromName(StartBeforeName);
377 StartAfter = getPassIDFromName(StartAfterName);
378 StopBefore = getPassIDFromName(StopBeforeName);
379 StopAfter = getPassIDFromName(StopAfterName);
352380 if (StartBefore && StartAfter)
353381 report_fatal_error(Twine(StartBeforeOptName) + Twine(" and ") +
354382 Twine(StartAfterOptName) + Twine(" specified!"));
492520 // and shouldn't reference it.
493521 AnalysisID PassID = P->getPassID();
494522
495 if (StartBefore == PassID)
523 if (StartBefore == PassID && StartBeforeCount++ == StartBeforeInstanceNum)
496524 Started = true;
497 if (StopBefore == PassID)
525 if (StopBefore == PassID && StopBeforeCount++ == StopBeforeInstanceNum)
498526 Stopped = true;
499527 if (Started && !Stopped) {
500528 std::string Banner;
517545 } else {
518546 delete P;
519547 }
520 if (StopAfter == PassID)
548
549 if (StopAfter == PassID && StopAfterCount++ == StopAfterInstanceNum)
521550 Stopped = true;
522 if (StartAfter == PassID)
551
552 if (StartAfter == PassID && StartAfterCount++ == StartAfterInstanceNum)
523553 Started = true;
524554 if (Stopped && !Started)
525555 report_fatal_error("Cannot stop compilation after pass that is not run");
0 ; RUN: not llc -debug-pass=Structure -stop-after=dead-mi-elimination,arst %s -o /dev/null 2>&1 \
1 ; RUN: | FileCheck -check-prefix=NOT-NUM %s
2
3 ; NOT-NUM: LLVM ERROR: invalid pass instance specifier dead-mi-elimination,arst
0 ; RUN: llc -debug-pass=Structure -stop-after=dead-mi-elimination,1 %s -o /dev/null 2>&1 \
1 ; RUN: | FileCheck -check-prefix=STOP-AFTER-DEAD1 %s
2
3 ; RUN: llc -debug-pass=Structure -stop-after=dead-mi-elimination,0 %s -o /dev/null 2>&1 \
4 ; RUN: | FileCheck -check-prefix=STOP-AFTER-DEAD0 %s
5
6
7 ; RUN: llc -debug-pass=Structure -stop-before=dead-mi-elimination,1 %s -o /dev/null 2>&1 \
8 ; RUN: | FileCheck -check-prefix=STOP-BEFORE-DEAD1 %s
9
10
11 ; RUN: llc -debug-pass=Structure -start-before=dead-mi-elimination,1 %s -o /dev/null 2>&1 \
12 ; RUN: | FileCheck -check-prefix=START-BEFORE-DEAD1 %s
13
14 ; RUN: llc -debug-pass=Structure -start-after=dead-mi-elimination,1 %s -o /dev/null 2>&1 \
15 ; RUN: | FileCheck -check-prefix=START-AFTER-DEAD1 %s
16
17
18
19 ; STOP-AFTER-DEAD1: -dead-mi-elimination
20 ; STOP-AFTER-DEAD1-SAME: -dead-mi-elimination
21
22 ; STOP-AFTER-DEAD1: Remove dead machine instructions
23 ; STOP-AFTER-DEAD1: Remove dead machine instructions
24
25
26
27 ; STOP-AFTER-DEAD0: -dead-mi-elimination
28
29 ; STOP-AFTER-DEAD0-NOT: Remove dead machine instructions
30 ; STOP-AFTER-DEAD0: Remove dead machine instructions
31 ; STOP-AFTER-DEAD0-NOT: Remove dead machine instructions
32
33
34
35 ; STOP-BEFORE-DEAD1: -dead-mi-elimination
36 ; STOP-BEFORE-DEAD1: Remove dead machine instructions
37 ; STOP-BEFORE-DEAD1-NOT: Remove dead machine instructions
38
39
40
41 ; START-BEFORE-DEAD1: -dead-mi-elimination
42 ; START-BEFORE-DEAD1-NOT: Remove dead machine instructions
43 ; START-BEFORE-DEAD1: Remove dead machine instructions
44 ; START-BEFORE-DEAD1-NOT: Remove dead machine instructions
45
46
47
48 ; START-AFTER-DEAD1-NOT: -dead-mi-elimination
49 ; START-AFTER-DEAD1-NOT: Remove dead machine instructions