]> granicus.if.org Git - llvm/commit
[PeepholeOptimizer] Don't assume bitcast def always has input
authorJinsong Ji <jji@us.ibm.com>
Mon, 19 Aug 2019 14:19:04 +0000 (14:19 +0000)
committerJinsong Ji <jji@us.ibm.com>
Mon, 19 Aug 2019 14:19:04 +0000 (14:19 +0000)
commit5607491df22cb35f063580e6e3ed04daa17f2fb6
tree50b12c94b60ffa9075f530645e3d8f24ab0597fb
parentc1e1ac2f6fdd7f5d08ef59182d931f929a442312
[PeepholeOptimizer] Don't assume bitcast def always has input

Summary:
If we have a MI marked with bitcast bits, but without input operands,
PeepholeOptimizer might crash with assert.

eg:
If we apply the changes in PPCInstrVSX.td as in this patch:

[(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;

We will get assert in PeepholeOptimizer.

```
llvm-lit llvm-project/llvm/test/CodeGen/PowerPC/build-vector-tests.ll -v

llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:417: const
llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
const: Assertion `i < getNumOperands() && "getOperand() out of range!"'
failed.
```

The fix is to abort if we found out of bound access.

Reviewers: qcolombet, MatzeB, hfinkel, arsenm

Reviewed By: qcolombet

Subscribers: wdng, arsenm, steven.zhang, wuzish, nemanjai, hiraditya, kbarton, MaskRay, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65542

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369261 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/PeepholeOptimizer.cpp
lib/Target/PowerPC/PPCInstrVSX.td
test/CodeGen/PowerPC/bitcast-peephole.mir [new file with mode: 0644]