[llvm-bugs] [Bug 45576] New: [GlobalISel] Assertion failure after IRTranslator translates complex ConstantExpr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 16 07:50:39 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45576

            Bug ID: 45576
           Summary: [GlobalISel] Assertion failure after IRTranslator
                    translates complex ConstantExpr
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: GlobalISel
          Assignee: unassignedbugs at nondot.org
          Reporter: jay.foad at gmail.com
                CC: llvm-bugs at lists.llvm.org, quentin.colombet at gmail.com

Created attachment 23375
  --> https://bugs.llvm.org/attachment.cgi?id=23375&action=edit
test case

With the attached test case I get:


$ llc -march=aarch64 -global-isel -verify-machineinstrs < r.ll
# After IRTranslator
# Machine code for function main: IsSSA, TracksLiveness

bb.1 (%ir-block.0):
  %6:_(s32) = G_CONSTANT i32 -1
  %5:_(p0) = G_INTTOPTR %6:_(s32)
  %7:_(p0) = G_GLOBAL_VALUE @var
  %4:_(s1) = G_ICMP intpred(eq), %5:_(p0), %7:_
  %3:_(s32) = G_ZEXT %4:_(s1)
  %2:_(s32) = COPY %3:_(s32)
  %0:_(s32) = COPY %1:_(s32)
  $w0 = COPY %0:_(s32)
  RET_ReallyLR implicit $w0

# End machine code for function main.

*** Bad machine code: Reading virtual register without a def ***
- function:    main
- basic block: %bb.1  (0x90f1c88)
- instruction: %0:_(s32) = COPY %1:_(s32)
- operand 1:   %1:_
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.


I think the problem is in IRTranslator::translate(const Constant &C, Register
Reg). If C is a ConstantExpr it does this:

  } else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
    switch(CE->getOpcode()) {
#define HANDLE_INST(NUM, OPCODE, CLASS)                                       
\
  case Instruction::OPCODE:                                                   
\
    return translate##OPCODE(*CE, *EntryBuilder.get());
#include "llvm/IR/Instruction.def"

... which completely ignores the "Reg" argument and generates the result into
some other register of its choosing. I can't see how this has ever worked.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200416/a8e71a93/attachment.html>


More information about the llvm-bugs mailing list