File tree Expand file tree Collapse file tree 2 files changed +52
-7
lines changed Expand file tree Collapse file tree 2 files changed +52
-7
lines changed Original file line number Diff line number Diff line change @@ -1746,7 +1746,6 @@ void AsmPrinter::emitFunctionBody() {
1746
1746
if (!MI.isPosition () && !MI.isImplicitDef () && !MI.isKill () &&
1747
1747
!MI.isDebugInstr ()) {
1748
1748
HasAnyRealCode = true ;
1749
- ++NumInstsInFunction;
1750
1749
}
1751
1750
1752
1751
// If there is a pre-instruction symbol, emit a label for it here.
@@ -1845,12 +1844,23 @@ void AsmPrinter::emitFunctionBody() {
1845
1844
break ;
1846
1845
default :
1847
1846
emitInstruction (&MI);
1848
- if (CanDoExtraAnalysis) {
1849
- MCInst MCI;
1850
- MCI.setOpcode (MI.getOpcode ());
1851
- auto Name = OutStreamer->getMnemonic (MCI);
1852
- auto I = MnemonicCounts.insert ({Name, 0u });
1853
- I.first ->second ++;
1847
+ auto CountInstruction = [&](unsigned Opcode) {
1848
+ ++NumInstsInFunction;
1849
+ if (CanDoExtraAnalysis) {
1850
+ MCInst MCI;
1851
+ MCI.setOpcode (Opcode);
1852
+ auto Name = OutStreamer->getMnemonic (MCI);
1853
+ ++MnemonicCounts[Name];
1854
+ }
1855
+ };
1856
+ if (!MI.isBundle ()) {
1857
+ CountInstruction (MI.getOpcode ());
1858
+ break ;
1859
+ }
1860
+ // Separately count all the instructions in a bundle.
1861
+ for (auto It = std::next (MI.getIterator ());
1862
+ It != MBB.end () && It->isInsideBundle (); ++It) {
1863
+ CountInstruction (It->getOpcode ());
1854
1864
}
1855
1865
break ;
1856
1866
}
Original file line number Diff line number Diff line change
1
+ # RUN: llc -mtriple=riscv32 -verify-machineinstrs -start-before=riscv-expand-pseudo -simplify-mir -o /dev/null -pass-remarks-analysis=asm-printer %s 2>&1 | FileCheck %s
2
+ ---
3
+ name : instrs
4
+ tracksRegLiveness : true
5
+ body : |
6
+ bb.0:
7
+ $x0 = ADDI $x0, 0
8
+ $x0 = ADDI $x0, 0
9
+ $x0 = ADDI $x0, 0
10
+ $x0 = LW $x0, 0
11
+ $x0 = LW $x0, 0
12
+ $x0 = XORI $x0, 0
13
+ ; CHECK: addi : 3
14
+ ; CHECK-NEXT: lw : 2
15
+ ; CHECK-NEXT: xori : 1
16
+ ; CHECK: 6 instructions in function
17
+ ...
18
+ ---
19
+ name : bundles
20
+ tracksRegLiveness : true
21
+ body : |
22
+ bb.0:
23
+ $x0 = ADDI $x0, 0
24
+ BUNDLE {
25
+ $x0 = ADDI $x0, 0
26
+ $x0 = ADDI $x0, 0
27
+ $x0 = LW $x0, 0
28
+ }
29
+ $x0 = LW $x0, 0
30
+ $x0 = XORI $x0, 0
31
+ ; CHECK: addi : 3
32
+ ; CHECK-NEXT: lw : 2
33
+ ; CHECK-NEXT: xori : 1
34
+ ; CHECK: 6 instructions in function
35
+ ...
You can’t perform that action at this time.
0 commit comments