[exegesis] SnippetRepetitor: don't deal with terminator instructions
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 8 Dec 2022 02:00:36 +0000 (05:00 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 8 Dec 2022 02:14:52 +0000 (05:14 +0300)
commit7c36fcfbbae1fc9b55257f621dbb0bc8d241e5c9
treeb62299252691a4fe78109010082abe30609f8597
parentfd52305fdc7572534867247c8fb66093faf52e5c
[exegesis] SnippetRepetitor: don't deal with terminator instructions

These appear to be the only two crashing issues.
Afterwards, we seem to not crash for all opcodes in all repetition modes
in all measurement modes.

Otherwise, we get:
```
#
# Machine code for function foo: NoPHIs, TracksLiveness, NoVRegs

bb.0:
  successors: %bb.1(0x80000000); %bb.1(100.00%)

  $r8 = MOV64ri 2

bb.1:
; predecessors: %bb.0, %bb.1
  successors: %bb.1(0x80000000), %bb.2(0x00000000); %bb.1(100.00%), %bb.2(0.00%)
  liveins: $r8
  HLT
  HLT
  $r8 = ADD64ri8 $r8(tied-def 0), -1, implicit-def $eflags
  JCC_1 %bb.1, 5, implicit $eflags

bb.2:
; predecessors: %bb.1

  RET64

# End machine code for function foo.

*** Bad machine code: Non-terminator instruction after the first terminator ***
- function:    foo
- basic block: %bb.1  (0x55df06791048)
- instruction: $r8 = ADD64ri8 $r8(tied-def 0), -1, implicit-def $eflags
First terminator was:   HLT
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: bin/llvm-exegesis --skip-measurements -mode=uops --dump-object-to-disk=0 --repetition-mode=loop --loop-body-size=1000 --result-aggregation-mode=min --opcode-name=HLT --max-configs-per-opcode=8192
1.      Running pass 'Function Pass Manager' on module 'ExegesisInfoTest'.
2.      Running pass 'Verify generated machine code' on function '@foo'

```
llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s [new file with mode: 0644]
llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp