File tree Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Original file line number Diff line number Diff line change @@ -1724,7 +1724,6 @@ void AsmPrinter::emitFunctionBody() {
1724
1724
if (!MI.isPosition () && !MI.isImplicitDef () && !MI.isKill () &&
1725
1725
!MI.isDebugInstr ()) {
1726
1726
HasAnyRealCode = true ;
1727
- ++NumInstsInFunction;
1728
1727
}
1729
1728
1730
1729
// If there is a pre-instruction symbol, emit a label for it here.
@@ -1816,11 +1815,22 @@ void AsmPrinter::emitFunctionBody() {
1816
1815
default :
1817
1816
emitInstruction (&MI);
1818
1817
if (CanDoExtraAnalysis) {
1819
- MCInst MCI;
1820
- MCI.setOpcode (MI.getOpcode ());
1821
- auto Name = OutStreamer->getMnemonic (MCI);
1822
- auto I = MnemonicCounts.insert ({Name, 0u });
1823
- I.first ->second ++;
1818
+ auto CountInstruction = [&](unsigned Opcode) {
1819
+ MCInst MCI;
1820
+ MCI.setOpcode (Opcode);
1821
+ auto Name = OutStreamer->getMnemonic (MCI);
1822
+ ++MnemonicCounts[Name];
1823
+ ++NumInstsInFunction;
1824
+ };
1825
+ if (!MI.isBundle ()) {
1826
+ CountInstruction (MI.getOpcode ());
1827
+ break ;
1828
+ }
1829
+ // Separately count all the instructions in a bundle.
1830
+ for (auto It = std::next (MI.getIterator ());
1831
+ It != MBB.end () && It->isInsideBundle (); ++It) {
1832
+ CountInstruction (It->getOpcode ());
1833
+ }
1824
1834
}
1825
1835
break ;
1826
1836
}
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