<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 --- - MI Serialization crashes on empty inlineasm"
   href="https://llvm.org/bugs/show_bug.cgi?id=24631">24631</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MI Serialization crashes on empty inlineasm
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hfinkel@anl.gov
          </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=14795" name="attach_14795" title="reduced test case">attachment 14795</a> <a href="attachment.cgi?id=14795&action=edit" title="reduced test case">[details]</a></span>
reduced test case

$ cat mirp.ll 
target datalayout = "E-m:e-i64:64-n32:64"
target triple = "powerpc64-unknown-linux-gnu"

define void @foo() #0 {
entry:
  tail call void asm sideeffect "", "~{memory}"() #0
  ret void
}

attributes #0 = { nounwind }

$ llc -stop-after=if-converter < mirp.ll 
llc: /src/llvm/lib/IR/AsmWriter.cpp:346: void
llvm::printLLVMNameWithoutPrefix(llvm::raw_ostream&, llvm::StringRef):
Assertion `!Name.empty() && "Cannot get empty name!"' failed.

The problem seems related to how llvm::MIPrinter::print handles external
symbols, specifically:

789      case MachineOperand::MO_ExternalSymbol:
790        OS << '$';
791        printLLVMNameWithoutPrefix(OS, Op.getSymbolName());
792        printOffset(Op.getOffset());
793        break;

printLLVMNameWithoutPrefix cannot be called with an empty name string, but it
is in this case because the inline asm string is empty:

  INLINEASM <es:> [sideeffect] [mayload] [maystore] [attdialect]</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>