• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: not llc -mtriple=aarch64-- -run-pass=legalizer %s -o - 2>&1 | FileCheck %s
2# REQUIRES: asserts
3
4# This is to demonstrate what kind of bugs we're missing w/o some kind
5# of validation for LegalizerInfo: G_INTTOPTR could only be legal /
6# could be legalized if its destination operand has a pointer type and
7# its source - a scalar type of an appropriate size. This test meets
8# the requirements for type index 0 (the pointer) and LLT-size
9# requirements for type index 1 (64 bits for AArch64), but has a
10# non-scalar (vector) type for type index 1. The Legalizer is expected
11# to fail on it with an appropriate error message. Prior to
12# LegalizerInfo::verify AArch64 legalizer had a subtle bug in its
13# definition that caused it to accept the following MIR as legal.
14# Namely, it checked that type index 0 is either s64 or p0 and
15# implicitly declared any type for type index 1 as legal (as soon as
16# its size is 64 bits). As LegalizerInfo::verify asserts on such a
17# definition due to type index 1 not being covered by a specific
18# action (not just `unsupportedIf`) it forces to review the definition
19# and fix the mistake: check that type index 0 is p0 and type index 1
20# is s64.
21
22# CHECK:      LLVM ERROR: unable to legalize instruction:
23# CHECK-SAME: %{{[0-9]+}}:_(p0) = G_INTTOPTR %{{[0-9]+}}:_(<4 x s16>)
24# CHECK-SAME: (in function: broken)
25
26---
27name:            broken
28alignment:       2
29tracksRegLiveness: true
30registers:
31  - { id: 0, class: _ }
32  - { id: 1, class: _ }
33body:             |
34  bb.1:
35    liveins: $d0
36
37    %0:_(<4 x s16>) = COPY $d0
38    %1:_(p0) = G_INTTOPTR %0(<4 x s16>)
39    $x0 = COPY %1(p0)
40    RET_ReallyLR implicit $x0
41
42...
43