Bugzilla – Bug 802
CBE lacks inline asm support
Last modified: 2009-05-20 09:40:43
You need to log in before you can comment on or make changes to this bug.
The C backend, at least when the C is compiled by GCC, should be able to change LLVM inline asm back into GCC-style inline asm in the cbe.c file. Right now, we just output an unresolved symbol when inline asm is used. -Chris
*** Bug 1212 has been marked as a duplicate of this bug. ***
*** Bug 1254 has been marked as a duplicate of this bug. ***
*** Bug 2102 has been marked as a duplicate of this bug. ***
Since a few days, the MultiSource/Benchmarks/Prolangs-C/archie-client from the test suite is failing, probably due inline ASM being used. I just finished creating a reduced testcase for that, which might be redundant now I read this bug. I'll still attach it, feel free to thrash it if it is not helpful. If this a different issue, I'll open a new report instead. The output of the attached program is as follows: kooijman@eris:~$ llvm-gcc -c test.c -o - -emit-llvm | llc -march=c -f -o test.cbe.c; gcc test.cbe.c test.cbe.c:132: warning: conflicting types for built-in function ‘malloc’ test.cbe.c: In function ‘main’: test.cbe.c:187: error: expected ‘:’ or ‘)’ before string constant test.cbe.c:163: warning: return type of ‘main’ is not ‘int’
Created an attachment (id=1759) [details] Reduced testcase from the archie-client test
*** Bug 2785 has been marked as a duplicate of this bug. ***
Is there any workaround for this issue? Thanks. -Arif
(In reply to comment #7) > Is there any workaround for this issue? Thanks. Yes, surely. Don't use inline asm :)
*** Bug 2839 has been marked as a duplicate of this bug. ***
I use llvm to instrument (C) programs and have bumped into this issue as well. In fact, I had to edit the CBE generated .c file to fix the inline asm and I have traced the failures I encountered back to three separate bugs in lib/Target/CBackend/CBackend.cpp: 1) in the visitInlineAsm function there are three loops for traversing and printing constraints, which should be separated by commas. This fails because the 'IsFirst' boolean, which should make sure a comma is printed before the constraint if it is not the first in the line, is only set to false whenever the boolean is false (never happens). Simple fix is to set it false outside the if-statement... 2) in the same function the clobber constraints (third loop) are not preceded by a ':'. 3) the gccifyAsm function somehow prints some register names with '%%regname' in stead of '$regname' For the project I am working on, I limited to the use LLVM version 2.4 only, so right now I am not able to active develop or bugfix the LLVM tools, and I have checked the latest version of CBackend.cpp, but it did not contain fixes for the bugs. I hope that someone more involved will address it, since it takes up unnecessary time fixing the faults in the resulting files, and I'm sure more people have encountered it. Greetings, Tom