<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Crash in InstrEmitter, Assertion `I != VRBaseMap.end() && "Node emitted out of order - late"'"
   href="http://llvm.org/bugs/show_bug.cgi?id=22614">22614</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash in InstrEmitter, Assertion `I != VRBaseMap.end() && "Node emitted out of order - late"'
          </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>normal
          </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>patrik.h.hagglund@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13883" name="attach_13883" title="test.c">attachment 13883</a> <a href="attachment.cgi?id=13883&action=edit" title="test.c">[details]</a></span>
test.c

Testcase for r229467:

a, b, c;
f() {
  b = c & 1 ? a : a - c;
}

bin/clang -w -emit-llvm -S test.c -o test.ll
bin/opt -S -inline -simplifycfg -instcombine test.ll -o test.opt.ll
bin/llc -march x86-64 -mcpu=corei7 -pre-RA-sched=linearize -o test.s
test.opt.ll

test.opt.ll:

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

@c = common global i32 0, align 4
@a = common global i32 0, align 4
@b = common global i32 0, align 4

define i32 @f() {
entry:
  %retval = alloca i32, align 4
  %0 = load i32* @c, align 4
  %and = and i32 %0, 1
  %tobool = icmp ne i32 %and, 0
  %1 = load i32* @a, align 4
  %sub = select i1 %tobool, i32 0, i32 %0
  %cond = sub nsw i32 %1, %sub
  store i32 %cond, i32* @b, align 4
  %2 = load i32* %retval, align 4
  ret i32 %2
}


llc: ../lib/CodeGen/SelectionDAG/InstrEmitter.cpp:302: unsigned int
llvm::InstrEmitter::getVR(llvm::SDValue, llvm::DenseMap<llvm::SDValue, unsigned
int>&): Assertion `I != VRBaseMap.end() && "Node emitted out of order - late"'
failed.
0  llc             0x0000000001e2b607 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  llc             0x0000000001e2b89d
2  llc             0x0000000001e2a54d
3  libpthread.so.0 0x00007fd027c1e810
4  libc.so.6       0x00007fd027439755 gsignal + 53
5  libc.so.6       0x00007fd02743ad31 abort + 385
6  libc.so.6       0x00007fd027432610 __assert_fail + 240
7  llc             0x0000000001d5c9cd llvm::InstrEmitter::getVR(llvm::SDValue,
llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo<llvm::SDValue>,
llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&) + 465
8  llc             0x0000000001d5cb51
llvm::InstrEmitter::AddRegisterOperand(llvm::MachineInstrBuilder&,
llvm::SDValue, unsigned int, llvm::MCInstrDesc const*,
llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo<llvm::SDValue>,
llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&, bool, bool, bool) +
357
9  llc             0x0000000001d5cfaa
llvm::InstrEmitter::AddOperand(llvm::MachineInstrBuilder&, llvm::SDValue,
unsigned int, llvm::MCInstrDesc const*, llvm::DenseMap<llvm::SDValue, unsigned
int, llvm::DenseMapInfo<llvm::SDValue>,
llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&, bool, bool, bool) +
196
10 llc             0x0000000001d5f01c
llvm::InstrEmitter::EmitMachineNode(llvm::SDNode*, bool, bool,
llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo<llvm::SDValue>,
llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&) + 1042
11 llc             0x0000000001c855b3
12 llc             0x0000000001c88bf1
13 llc             0x0000000001d273af
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 4553
14 llc             0x0000000001d25ea0
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 234
15 llc             0x0000000001d29363
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3015
16 llc             0x0000000001d250be
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 992
17 llc             0x000000000137f02f
18 llc             0x000000000175f1b3
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
19 llc             0x0000000001a77cfc
llvm::FPPassManager::runOnFunction(llvm::Function&) + 290
20 llc             0x0000000001a77e6c
llvm::FPPassManager::runOnModule(llvm::Module&) + 84
21 llc             0x0000000001a781c0
22 llc             0x0000000001a78876
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 250
23 llc             0x0000000001a78a97
llvm::legacy::PassManager::run(llvm::Module&) + 39
24 llc             0x0000000000c0396e
25 llc             0x0000000000c02b47 main + 237
26 libc.so.6       0x00007fd027425c16 __libc_start_main + 230
27 llc             0x0000000000bffd29
Stack dump:
0.      Program arguments: ../build-all-gcc49-Debug/bin/llc -march x86-64
-mcpu=corei7 -pre-RA-sched=linearize -o test.s test.opt.ll
1.      Running pass 'Function Pass Manager' on module 'test.opt.ll'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
Abort (core dumped)</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>