<html>
    <head>
      <base href="https://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 --- - ""Node emitted out of order - late" compiling to WASM"
   href="https://llvm.org/bugs/show_bug.cgi?id=27329">27329</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>""Node emitted out of order - late" compiling to WASM
          </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>Windows NT
          </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: WebAssembly
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>gareth_morgan77@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16209" name="attach_16209" title="Test case with CPP, LL and .s files (with makefile)">attachment 16209</a> <a href="attachment.cgi?id=16209&action=edit" title="Test case with CPP, LL and .s files (with makefile)">[details]</a></span>
Test case with CPP, LL and .s files (with makefile)

The attached Basic.ll file will cause this assert in LLC:
Assertion failed: I != VRBaseMap.end() && "Node emitted out of order - late",
file E:\testcode\llvm\llvm-3.8.0.src\lib\CodeGen\SelectionDAG\InstrEmitter.cpp,
line 302

Changing the argument to the Bar function to pass by value, rather than
reference makes the assert go away (Basic.works.cpp and Basic.opt.works.ll
attached).

Testcase (and makefile showing build steps) attached.

Callstack below
<span class="quote">>        llc.exe!llvm::InstrEmitter::getVR(llvm::SDValue Op, llvm::DenseMap<llvm::SDValue,unsigned int,llvm::DenseMapInfo<llvm::SDValue>,llvm::detail::DenseMapPair<llvm::SDValue,unsigned int> > & VRBaseMap) Line 302    C++</span >
     llc.exe!llvm::InstrEmitter::EmitSpecialNode(llvm::SDNode * Node, bool
IsClone, bool IsCloned, llvm::DenseMap<llvm::SDValue,unsigned
int,llvm::DenseMapInfo<llvm::SDValue>,llvm::detail::DenseMapPair<llvm::SDValue,unsigned
int> > & VRBaseMap) Line 901    C++
     llc.exe!llvm::InstrEmitter::EmitNode(llvm::SDNode * Node, bool IsClone,
bool IsCloned, llvm::DenseMap<llvm::SDValue,unsigned
int,llvm::DenseMapInfo<llvm::SDValue>,llvm::detail::DenseMapPair<llvm::SDValue,unsigned
int> > & VRBaseMap) Line 124    C++
    
llc.exe!llvm::ScheduleDAGSDNodes::EmitSchedule(llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr,llvm::ilist_iterator<llvm::MachineInstr>
<span class="quote">> & InsertPos) Line 848    C++</span >
     llc.exe!llvm::SelectionDAGISel::CodeGenAndEmitDAG() Line 867    C++
    
llc.exe!llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const > Begin, llvm::ilist_iterator<llvm::Instruction const > End, bool &
HadTailCall) Line 669    C++
     llc.exe!llvm::SelectionDAGISel::SelectAllBasicBlocks(const llvm::Function
& Fn) Line 1362    C++
     llc.exe!llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction
& mf) Line 507    C++
     llc.exe!`anonymous
namespace'::WebAssemblyDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction
& MF) Line 55    C++
     llc.exe!llvm::MachineFunctionPass::runOnFunction(llvm::Function & F) Line
44    C++
     llc.exe!llvm::FPPassManager::runOnFunction(llvm::Function & F) Line 1550  
 C++
     llc.exe!llvm::FPPassManager::runOnModule(llvm::Module & M) Line 1571   
C++
     llc.exe!`anonymous namespace'::MPPassManager::runOnModule(llvm::Module &
M) Line 1627    C++
     llc.exe!llvm::legacy::PassManagerImpl::run(llvm::Module & M) Line 1730   
C++
     llc.exe!llvm::legacy::PassManager::run(llvm::Module & M) Line 1762    C++
     llc.exe!compileModule(char * * argv, llvm::LLVMContext & Context) Line 408
   C++
     llc.exe!main(int argc, char * * argv) Line 211    C++</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>