<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61438>61438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assert in X86AsmParser::ParseMemOperand when passing two segment prefixes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
llvm:asmparser
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ramosian-glider
</td>
</tr>
</table>
<pre>
The following code:
```
void foo() {
asm("movq $0, %cs:%ds:(%rax)");
}
```
triggers an assertion in `X86AsmParser::ParseMemOperand()`:
```
clang: /root/llvm-project/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2946: bool {anonymous}::X86AsmParser::ParseMemOperand(unsigned int, const llvm::MCExpr*, llvm::SMLoc, llvm::SMLoc, llvm::OperandVector&): Assertion `!isa<X86MCExpr>(Disp) && "Expected non-register here."' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'X86 Assembly Printer' on function '@foo'
#0 0x000055a44e7bcdff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3febdff)
#1 0x000055a44e7bab3c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fe9b3c)
```
Godbolt link: https://godbolt.org/z/b381Werh9
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TX0ZSCDpmR9HHzwOnYvG2zQLNrcCoocyWwoUiWpjdNf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