Issue |
95239
|
Summary |
[Clang] Confuse an memory operand as immediate value.
|
Labels |
clang
|
Assignees |
|
Reporter |
witbring
|
I discovered that the latest Clang transforms memory operands to immediate value.
This error has been identified in 23(24) opcodes when I tested x64(x86) assembly.
Buggy Code (x64)
```
.intel_syntax noprefix
Bug:
ja QWORD PTR [1]
jae QWORD PTR [1]
jb QWORD PTR [1]
je QWORD PTR [1]
jecxz QWORD PTR [1]
jg QWORD PTR [1]
jl QWORD PTR [1]
jo QWORD PTR [1]
jp QWORD PTR [1]
js QWORD PTR [1]
jae QWORD PTR [1]
jbe QWORD PTR [1]
jge QWORD PTR [1]
jle QWORD PTR [1]
jne QWORD PTR [1]
jno QWORD PTR [1]
jnp QWORD PTR [1]
jnp QWORD PTR [1]
jns QWORD PTR [1]
loop QWORD PTR [1]
loope QWORD PTR [1]
loopne QWORD PTR [1]
xbegin QWORD PTR [1]
```
Compiled code (x64)
```
Bug:
ja 6 <Bug+0x6>
jae c <Bug+0xc>
jb 12 <Bug+0x12>
je 18 <Bug+0x18>
jecxz 1b <Bug+0x1b>
jg 21 <Bug+0x21>
jl 27 <Bug+0x27>
jo 2d <Bug+0x2d>
jp 33 <Bug+0x33>
js 39 <Bug+0x39>
jae 3f <Bug+0x3f>
jbe 45 <Bug+0x45>
jge 4b <Bug+0x4b>
jle 51 <Bug+0x51>
jne 57 <Bug+0x57>
jno 5d <Bug+0x5d>
jnp 63 <Bug+0x63>
jnp 69 <Bug+0x69>
jns 6f <Bug+0x6f>
loop 71 <Bug+0x71>
loope 73 <Bug+0x73>
loopne 75 <Bug+0x75>
xbegin 7b <Bug+0x7b>
```
Buggy Code (x86)
```
.intel_syntax noprefix
Bug:
ja QWORD PTR [1]
jb QWORD PTR [1]
jcxz QWORD PTR [1]
je QWORD PTR [1]
jecxz QWORD PTR [1]
jg QWORD PTR [1]
jl QWORD PTR [1]
jo QWORD PTR [1]
jp QWORD PTR [1]
js QWORD PTR [1]
jae QWORD PTR [1]
jbe QWORD PTR [1]
jge QWORD PTR [1]
jle QWORD PTR [1]
jne QWORD PTR [1]
jno QWORD PTR [1]
jnp QWORD PTR [1]
jnp QWORD PTR [1]
jns QWORD PTR [1]
loop QWORD PTR [1]
loope QWORD PTR [1]
loopne QWORD PTR [1]
xbegin QWORD PTR [1]
```
Compiled Code (x86)
```
Bug:
ja 3 <Bug+0x3>
jb 9 <Bug+0x9>
jcxz f <Bug+0xf>
je 12 <Bug+0x12>
jecxz 17 <Bug+0x17>
jg 1a <Bug+0x1a>
jl 20 <Bug+0x20>
jo 26 <Bug+0x26>
jp 2c <Bug+0x2c>
js 32 <Bug+0x32>
jae 38 <Bug+0x38>
jbe 3e <Bug+0x3e>
jge 44 <Bug+0x44>
jle 4a <Bug+0x4a>
jne 50 <Bug+0x50>
jno 56 <Bug+0x56>
jnp 5c <Bug+0x5c>
jnp 62 <Bug+0x62>
jns 68 <Bug+0x68>
loop 6d <Bug+0x6d>
loope 6f <Bug+0x6f>
loopne 71 <Bug+0x71>
xbegin 74 <Bug+0x74>
```
You can reproduce the bugs through godbolt site.
- x64: https://godbolt.org/z/jesbMqEsv
- x86: https://godbolt.org/z/8dTb3rvj4
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs