[PATCH] D65542: [PeepholeOptimizer] Don't assume bitcast def always has input

Jinsong Ji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 11:28:10 PDT 2019


jsji marked an inline comment as done.
jsji added inline comments.


================
Comment at: llvm/test/CodeGen/PowerPC/bitcast-peephole.mir:2
+# RUN: llc -mtriple=powerpc64le-linux-gnu -run-pass=peephole-opt -verify-machineinstrs -o - %s | FileCheck %s
+# REQUIRES: asserts
+
----------------
qcolombet wrote:
> qcolombet wrote:
> > Instead of requiring assertion, I would just explicitly check that the number of operands is correct.
> > You can use `update_mir_test_check.py` to generate the check lines for this.
> Scratch my last comment on the number of operands!
> Still would generating the CHECK lines with the update script would have caught the bug without having to rely on asserts?
I gave it a try. Unfotunately, no, we can't caught this without assert.

```
[~/build-nonassert] $ cat ../llvm-project/llvm/test/CodeGen/PowerPC/bitcast-peephole.mir
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=powerpc64le-linux-gnu -run-pass=peephole-opt -verify-machineinstrs -o - %s | FileCheck %s

---
name:            bitCast
tracksRegLiveness: true
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: bitCast
    ; CHECK: [[XXLEQVOnes:%[0-9]+]]:vsrc = XXLEQVOnes
    ; CHECK: $v2 = COPY [[XXLEQVOnes]]
    ; CHECK: BLR8 implicit $lr8, implicit $rm, implicit $v2
    %0:vsrc = XXLEQVOnes
    $v2 = COPY %0
    BLR8 implicit $lr8, implicit $rm, implicit $v2

...

# This used to hit an assertion:
#   llvm/include/llvm/CodeGen/MachineInstr.h:417: const
#   llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
#   const: Assertion `i < getNumOperands() && "getOperand() out of range!"' failed.
#
[~/build-nonassert] $ bin/llvm-lit ../llvm-project/llvm/test/CodeGen/PowerPC/bitcast-peephole.mir -v
-- Testing: 1 tests, single process --
PASS: LLVM :: CodeGen/PowerPC/bitcast-peephole.mir (1 of 1)
Testing Time: 0.04s
  Expected Passes    : 1

[~/build] $ bin/llvm-lit ../llvm-project/llvm/test/CodeGen/PowerPC/bitcast-peephole.mir 
-- Testing: 1 tests, single process --
FAIL: LLVM :: CodeGen/PowerPC/bitcast-peephole.mir (1 of 1)
Testing Time: 0.32s
********************
Failing Tests (1):
    LLVM :: CodeGen/PowerPC/bitcast-peephole.mir

  Unexpected Failures: 1

```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65542/new/

https://reviews.llvm.org/D65542





More information about the llvm-commits mailing list