[MachineVerifier][GlobalISel] Check that branches have a MBB operand or are declared indirect. Add missing properties to G_BRJT, G_BRINDIRECT
Summary:
Teach MachineVerifier to check branches for MBB operands if they are not declared indirect.
Add `isBarrier`, `isIndirectBranch` to `G_BRINDIRECT` and `G_BRJT`.
Without these, `MachineInstr.isConditionalBranch()` was giving a
false-positive for those instructions.
Reviewers: aemerson, qcolombet, dsanders, arsenm
Reviewed By: dsanders
Subscribers: hiraditya, wdng, simoncook, s.egerton, arsenm, rovka, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81587
2020-06-10 23:15:09 +08:00
|
|
|
# RUN: llc -march=riscv32 -o - -run-pass=none -verify-machineinstrs %s | FileCheck %s
|
2020-06-15 22:35:18 +08:00
|
|
|
# REQUIRES: riscv-registered-target
|
[MachineVerifier][GlobalISel] Check that branches have a MBB operand or are declared indirect. Add missing properties to G_BRJT, G_BRINDIRECT
Summary:
Teach MachineVerifier to check branches for MBB operands if they are not declared indirect.
Add `isBarrier`, `isIndirectBranch` to `G_BRINDIRECT` and `G_BRJT`.
Without these, `MachineInstr.isConditionalBranch()` was giving a
false-positive for those instructions.
Reviewers: aemerson, qcolombet, dsanders, arsenm
Reviewed By: dsanders
Subscribers: hiraditya, wdng, simoncook, s.egerton, arsenm, rovka, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81587
2020-06-10 23:15:09 +08:00
|
|
|
|
|
|
|
# This test checks that the G_BRJT is an indirect branch by leveraging RISCV's
|
|
|
|
# version of analyzeBranch. If G_BRJT would not be an indirect branch, this
|
|
|
|
# test would crash.
|
|
|
|
|
|
|
|
---
|
|
|
|
name: test_jump_table
|
|
|
|
legalized: true
|
|
|
|
tracksRegLiveness: true
|
|
|
|
jumpTable:
|
|
|
|
kind: block-address
|
|
|
|
entries:
|
|
|
|
- id: 0
|
|
|
|
blocks: [ '%bb.0' ]
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
liveins: $x0
|
|
|
|
%0:_(s32) = COPY $x0
|
|
|
|
%1:_(p0) = COPY $x0
|
|
|
|
|
|
|
|
; CHECK-NOT: Branch instruction is missing a basic block operand or isIndirectBranch property
|
|
|
|
G_BRJT %1, %jump-table.0, %0
|
|
|
|
|
|
|
|
...
|