<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - isREXExtendedReg called on non-reg operand of MRMDestMem"
   href="https://bugs.llvm.org/show_bug.cgi?id=48458">48458</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>isREXExtendedReg called on non-reg operand of MRMDestMem
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tim.besard@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following IR violates an assertion in the x86 machine code emitter on
current trunk:

```
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i1 @foo(i64* %0) {
top:
  %1 = load i64, i64* %0, !range !0
  %2 = icmp ult i64 %1, 2147483648
  ret i1 %2
}

!0 = !{i64 0, i64 10000000000}
```

The assertion and backtrace:

llc: llvm/include/llvm/MC/MCInst.h:65: unsigned int llvm::MCOperand::getReg()
const: Assertion `isReg() && "This is not a register operand!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0.      Program arguments: ./bin/llc ../wip.ll
1.      Running pass 'Function Pass Manager' on module '../wip.ll'.
2.      Running pass 'X86 Assembly Printer' on function '@foo'
 #0 0x00007f2d65e9914d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
llvm/lib/Support/Unix/Signals.inc:567:3
 #1 0x00007f2d65e96fe4 llvm::sys::RunSignalHandlers()
llvm/lib/Support/Signals.cpp:71:20
 #2 0x00007f2d65e97825 SignalHandler(int)
llvm/lib/Support/Unix/Signals.inc:395:31
 #3 0x00007f2d680fa700 __restore_rt
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libpthread.so.0+0x12700)
 #4 0x00007f2d6582441a raise
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libc.so.6+0x3841a)
 #5 0x00007f2d6580e523 abort
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libc.so.6+0x22523)
 #6 0x00007f2d6580e41f _nl_load_domain.cold.0
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libc.so.6+0x2241f)
 #7 0x00007f2d6581cd52
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libc.so.6+0x30d52)
 #8 0x00007f2d683d3af3 llvm/include/llvm/MC/MCInst.h:65:5
 #9 0x00007f2d683d3d4a llvm/include/llvm/ADT/SmallVector.h:250:5
#10 0x00007f2d683d5701 operator()
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1261:7
#11 0x00007f2d683d5701 emitREXPrefix
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1297:4
#12 0x00007f2d683d5701 emitOpcodePrefix
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1356:36
#13 0x00007f2d683d5701 (anonymous
namespace)::X86MCCodeEmitter::emitPrefixImpl(unsigned int&, llvm::MCInst
const&, llvm::MCSubtargetInfo const&, llvm::raw_ostream&) const
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:703:30
#14 0x00007f2d683d7b97 (anonymous
namespace)::X86MCCodeEmitter::encodeInstruction(llvm::MCInst const&,
llvm::raw_ostream&, llvm::SmallVectorImpl<llvm::MCFixup>&,
llvm::MCSubtargetInfo const&) const
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1427:16
#15 0x00007f2d6898c2f1
llvm::X86AsmPrinter::StackMapShadowTracker::count(llvm::MCInst&,
llvm::MCSubtargetInfo const&, llvm::MCCodeEmitter*) (.part.0)
llvm/lib/Target/X86/X86MCInstLower.cpp:110:23
#16 0x00007f2d6899409e llvm::SmallVectorTemplateCommon<llvm::MCOperand,
void>::end() llvm/include/llvm/ADT/SmallVector.h:224:35
#17 0x00007f2d6899409e llvm::SmallVector<llvm::MCOperand, 8u>::~SmallVector()
llvm/include/llvm/ADT/SmallVector.h:1026:5
#18 0x00007f2d6899409e llvm::MCInst::~MCInst()
llvm/include/llvm/MC/MCInst.h:158:7
#19 0x00007f2d6899409e llvm::X86AsmPrinter::emitInstruction(llvm::MachineInstr
const*) llvm/lib/Target/X86/X86MCInstLower.cpp:2613:10
#20 0x00007f2d681a35bc llvm::AsmPrinter::emitFunctionBody()
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1224:9
#21 0x00007f2d6871a32f
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&)
llvm/lib/Target/X86/X86AsmPrinter.cpp:85:16
#22 0x00007f2d675847b1
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
llvm/lib/CodeGen/MachineFunctionPass.cpp:72:33
#23 0x00007f2d675847b1
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
llvm/lib/CodeGen/MachineFunctionPass.cpp:37:6
#24 0x00007f2d662af3dd llvm::FPPassManager::runOnFunction(llvm::Function&)
llvm/lib/IR/LegacyPassManager.cpp:1450:7
#25 0x00007f2d662afea1
llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true,
false, void> >::getNext() llvm/include/llvm/ADT/ilist_node.h:66:66
#26 0x00007f2d662afea1
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true,
false, void>, false, false>::operator++()
llvm/include/llvm/ADT/ilist_iterator.h:157:25
#27 0x00007f2d662afea1 llvm::FPPassManager::runOnModule(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:1485:22
#28 0x00007f2d662aedb8 runOnModule llvm/lib/IR/LegacyPassManager.cpp:1562:7
#29 0x00007f2d662aedb8 llvm::legacy::PassManagerImpl::run(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:542:55
#30 0x000000000040cfb6 compileModule llvm/tools/llc/llc.cpp:661:66
#31 0x000000000040cfb6 main llvm/tools/llc/llc.cpp:363:35
#32 0x00007f2d6580fdbd __libc_start_main
(/nix/store/5didcr1sjp2rlx8abbzv92rgahsarqd9-glibc-2.32/lib/libc.so.6+0x23dbd)
#33 0x000000000040d84a _start
/build/glibc-2.32/csu/../sysdeps/x86_64/start.S:122:0

The MCInst in question: MRMDestMem: <MCInst 2993 <MCOperand Reg:53> <MCOperand
Imm:1> <MCOperand Reg:0> <MCOperand Imm:0> <MCOperand Reg:0> <MCOperand
Imm:-2147483648>>. The code calls isREXExtendedReg on the 5th operand, here an
immediate, which results in an abort. With other inputs this operand seems
always to be a register, but I'm not familiar with this part of LLVM to know if
I can just add an `isReg` check here, or whether this is something invalid in
the first place.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>