mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
GlobalISel: Verify g_zextload and g_sextload
llvm-svn: 351584
This commit is contained in:
parent
749ca38372
commit
55ec092e2c
@ -986,11 +986,24 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
|
||||
break;
|
||||
case TargetOpcode::G_LOAD:
|
||||
case TargetOpcode::G_STORE:
|
||||
case TargetOpcode::G_ZEXTLOAD:
|
||||
case TargetOpcode::G_SEXTLOAD:
|
||||
// Generic loads and stores must have a single MachineMemOperand
|
||||
// describing that access.
|
||||
if (!MI->hasOneMemOperand())
|
||||
if (!MI->hasOneMemOperand()) {
|
||||
report("Generic instruction accessing memory must have one mem operand",
|
||||
MI);
|
||||
} else {
|
||||
if (MI->getOpcode() == TargetOpcode::G_ZEXTLOAD ||
|
||||
MI->getOpcode() == TargetOpcode::G_SEXTLOAD) {
|
||||
const MachineMemOperand &MMO = **MI->memoperands_begin();
|
||||
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
|
||||
if (MMO.getSize() * 8 >= DstTy.getSizeInBits()) {
|
||||
report("Generic extload must have a narrower memory type", MI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TargetOpcode::G_PHI: {
|
||||
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
|
||||
|
23
test/CodeGen/MIR/AArch64/invalid-extload.mir
Normal file
23
test/CodeGen/MIR/AArch64/invalid-extload.mir
Normal file
@ -0,0 +1,23 @@
|
||||
# RUN: not llc -mtriple=aarch64-none-linux-gnu -run-pass none -o - %s 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: *** Bad machine code: Generic extload must have a narrower memory type ***
|
||||
# CHECK: *** Bad machine code: Generic extload must have a narrower memory type ***
|
||||
# CHECK: *** Bad machine code: Generic extload must have a narrower memory type ***
|
||||
# CHECK: *** Bad machine code: Generic extload must have a narrower memory type ***
|
||||
# CHECK: *** Bad machine code: Generic instruction accessing memory must have one mem operand ***
|
||||
# CHECK: *** Bad machine code: Generic instruction accessing memory must have one mem operand ***
|
||||
|
||||
---
|
||||
name: invalid_extload_memory_sizes
|
||||
body: |
|
||||
bb.0:
|
||||
|
||||
%0:_(p0) = COPY $x0
|
||||
%1:_(s64) = G_ZEXTLOAD %0(p0) :: (load 8)
|
||||
%2:_(s64) = G_ZEXTLOAD %0(p0) :: (load 16)
|
||||
%3:_(s64) = G_SEXTLOAD %0(p0) :: (load 8)
|
||||
%4:_(s64) = G_SEXTLOAD %0(p0) :: (load 16)
|
||||
%5:_(s64) = G_ZEXTLOAD %0(p0)
|
||||
%6:_(s64) = G_SEXTLOAD %0(p0)
|
||||
|
||||
...
|
Loading…
Reference in New Issue
Block a user