asm-parser
asm-parser copied to clipboard
Incorrect filtering of intrinsics
The following input:
bollo:~/d/c/asm-parser (main|✔) $ objdump -d /tmp/moo.o -l --insn-width=16 -r -C -M intel
/tmp/moo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <a(long long __vector(2))>:
_mm_bsrli_si128(long long __vector(2), int):
/opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/include/emmintrin.h:1217
0: 66 0f 73 d8 04 psrldq xmm0,0x4
a(long long __vector(2)):
//tmp/moo.cc:6
5: c3 ret
will ignore the psrldq instruction:
$ objdump -d /tmp/moo.o -l --insn-width=16 -r -C -M intel | ~/Downloads/asm-parser -plt -stdin -binary -unused_labels -directives -comment_only -library_functions
{"asm": [{"labels": [], "source": null, "text": "long __vector(2))::"},{"labels": [], "opcodes": ["c3"], "address": 5, "source": {"file": "//tmp/moo.cc", "mainsource": "false", "line": 6}, "text": " ret"}],"labelDefinitions": {"long __vector(2)):": 1}, "parsingTime": 2}
From compiler-explorer/compiler-explorer#6188
The line:
/opt/compiler-explorer/gcc-13.2.0/lib/gcc/x86_64-linux-gnu/13.2.0/include/emmintrin.h:1217
seems to be the thing that triggers the ignoring of the line after, even with just -plt -stdin -binary and no other filtering.
Yes, this definitely has something to do with that piece being inlined from immintrin.h. Considering that instruction to be library code is reasonable (everything in immintrin.h is tagged attribute((artificial)), so I suspect disassembly output shouldn't point to immintrin.h at all, but that's not a bug anywhere in CE).
Filtering library code when not asked to, less reasonable.
And deleting half of the line and printing long __vector(2)):: is not reasonable either. Looks like two different bugs to me; you may want to investigate the latter first, I suspect it may become hard to reproduce after fixing the library filtering thing.
The CE code correctly outputs this as:
{
"asm": [
{
"labels": [],
"source": null,
"text": "a(long long __vector(2)):"
},
{
"address": 0,
"labels": [],
"opcodes": [
"66",
"0f",
"73",
"d8",
"04"
],
"source": {
"file": null,
"line": 1217,
"mainsource": true
},
"text": " psrldq xmm0,0x4"
},
{
"address": 5,
"labels": [],
"opcodes": [
"c3"
],
"source": {
"file": null,
"line": 6,
"mainsource": true
},
"text": " ret"
}
],
"labelDefinitions": {
"a(long long __vector(2))": 1
}
}