[llvm-bugs] [Bug 39895] New: Error: unknown token in expression using inline asm
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 5 07:38:55 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39895
Bug ID: 39895
Summary: Error: unknown token in expression using inline asm
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: noloader at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
We have about 8K lines of inline assembly written to accommodate GCC and MSVC.
Clang is currently disabled but we would like to enable it.
The inline assembly in the production code is hidden behind macros. The body is
Intel and the assembler template is AT&T. GCC sees both while MSVC only sees
the Intel body without the other adornments.
Clang is having trouble with it. It looks like Clang handles the noprefix OK
because "xor rsi, rsi" does not cause an error. However, the positional
arguments are giving it trouble.
$ cat TestPrograms/test_mixed_asm.cxx
#include <cstddef>
int main(int argc, char* argv[])
{
size_t ret = 1, N = 0;
asm __volatile__
(
".intel_syntax noprefix ;\n"
"xor rsi, rsi ;\n"
"neg %1 ;\n"
"inc %1 ;\n"
"push %1 ;\n"
"pop rax ;\n"
".att_syntax prefix ;\n"
: "=a" (ret) : "c" (N) : "%rsi"
);
return (int)ret;
}
Compiling with GCC on Linux is OK:
$ g++ TestPrograms/test_mixed_asm.cxx
But Clang on Linux is having trouble:
$ clang++ TestPrograms/test_mixed_asm.cxx
TestPrograms/test_mixed_asm.cxx:11:4: error: unknown token in expression
"neg %1 ;\n"
^
<inline asm>:3:5: note: instantiated into assembly here
neg %rcx ;
^
TestPrograms/test_mixed_asm.cxx:12:4: error: unknown token in expression
"inc %1 ;\n"
^
<inline asm>:4:5: note: instantiated into assembly here
inc %rcx ;
^
TestPrograms/test_mixed_asm.cxx:13:4: error: unknown token in expression
"push %1 ;\n"
^
<inline asm>:5:6: note: instantiated into assembly here
push %rcx ;
^
3 errors generated.
And:
$ clang++ --version
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /bin
Jumping over to MacPorts for Clang 7:
$ /opt/local/bin/clang++-mp-7.0 TestPrograms/test_mixed_asm.cxx
TestPrograms/test_mixed_asm.cxx:11:4: error: unknown token in expression
"neg %1 ;\n"
^
<inline asm>:3:5: note: instantiated into assembly here
neg %rcx ;
^
TestPrograms/test_mixed_asm.cxx:12:4: error: unknown token in expression
"inc %1 ;\n"
^
<inline asm>:4:5: note: instantiated into assembly here
inc %rcx ;
^
TestPrograms/test_mixed_asm.cxx:13:4: error: unknown token in expression
"push %1 ;\n"
^
<inline asm>:5:6: note: instantiated into assembly here
push %rcx ;
^
3 errors generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181205/650b49cb/attachment-0001.html>
More information about the llvm-bugs
mailing list