Skip to content

Commit 264c07e

Browse files
committed
[llvm][MIRVRegNamer] Avoid collisions across jump table indices.
Hash Jump Table Indices uniquely within a basic block for MIR Canonicalizer / MIR VReg Renamer passes. Differential Revision: https://reviews.llvm.org/D77966
1 parent 430b009 commit 264c07e

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

llvm/lib/CodeGen/MIRVRegNamerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ std::string VRegRenamer::getInstructionOpcodeHash(MachineInstr &MI) {
7272
return MO.getOffset() | (MO.getTargetFlags() << 16);
7373
case MachineOperand::MO_FrameIndex:
7474
case MachineOperand::MO_ConstantPoolIndex:
75+
case MachineOperand::MO_JumpTableIndex:
7576
return llvm::hash_value(MO);
7677

7778
// We could explicitly handle all the types of the MachineOperand,
@@ -82,7 +83,6 @@ std::string VRegRenamer::getInstructionOpcodeHash(MachineInstr &MI) {
8283

8384
// TODO: Handle the following Index/ID/Predicate cases. They can
8485
// be hashed on in a stable manner.
85-
case MachineOperand::MO_JumpTableIndex:
8686
case MachineOperand::MO_CFIIndex:
8787
case MachineOperand::MO_IntrinsicID:
8888
case MachineOperand::MO_Predicate:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# RUN: llc -run-pass mir-canonicalizer -verify-machineinstrs -mtriple aarch64-unknown-linux-gnu -o - %s | FileCheck %s
2+
...
3+
---
4+
name: foo
5+
alignment: 16
6+
jumpTable:
7+
kind: block-address
8+
entries:
9+
- id: 0
10+
blocks: [ '%bb.0', '%bb.1']
11+
- id: 1
12+
blocks: [ '%bb.2', '%bb.3' ]
13+
- id: 2
14+
blocks: [ '%bb.3', '%bb.7']
15+
- id: 3
16+
blocks: [ '%bb.2', '%bb.3' ]
17+
body: |
18+
bb.0:
19+
bb.1:
20+
bb.2:
21+
bb.3:
22+
bb.7:
23+
;CHECK: %bb{{[0-9]+}}_{{[0-9]+}}__1:_(p0) = G_JUMP_TABLE %jump-table.0
24+
;CHECK: %bb{{[0-9]+}}_{{[0-9]+}}__1:_(p0) = G_JUMP_TABLE %jump-table.1
25+
;CHECK: %bb{{[0-9]+}}_{{[0-9]+}}__1:_(p0) = G_JUMP_TABLE %jump-table.2
26+
;CHECK: %bb{{[0-9]+}}_{{[0-9]+}}__1:_(p0) = G_JUMP_TABLE %jump-table.3
27+
%a:_(p0) = G_JUMP_TABLE %jump-table.0
28+
%b:_(p0) = G_JUMP_TABLE %jump-table.1
29+
%c:_(p0) = G_JUMP_TABLE %jump-table.2
30+
%d:_(p0) = G_JUMP_TABLE %jump-table.3
31+
32+
...
33+

0 commit comments

Comments
 (0)