Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBE lacks inline asm support #1174

Closed
lattner opened this issue Jun 8, 2006 · 21 comments
Closed

CBE lacks inline asm support #1174

lattner opened this issue Jun 8, 2006 · 21 comments
Labels
bugzilla Issues migrated from bugzilla missing-feature Feature requests? Is this different from [enhancement]? wontfix Resolved as "WON'T FIX." Not "INVALID" — the issue is real, but we can't or won't fix it

Comments

@lattner
Copy link
Collaborator

lattner commented Jun 8, 2006

Bugzilla Link 802
Resolution WONTFIX
Resolved on Mar 26, 2012 05:56
Version 1.0
OS All
Blocks llvm/llvm-bugzilla-archive#862
CC @asl,@d0k,@matthijskooijman,@nlewycky,@pwo

Extended Description

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

@lattner
Copy link
Collaborator Author

lattner commented Feb 20, 2007

*** Bug llvm/llvm-bugzilla-archive#1212 has been marked as a duplicate of this bug. ***

@lattner
Copy link
Collaborator Author

lattner commented Mar 25, 2007

*** Bug llvm/llvm-bugzilla-archive#1254 has been marked as a duplicate of this bug. ***

@lattner
Copy link
Collaborator Author

lattner commented Feb 27, 2008

*** Bug llvm/llvm-bugzilla-archive#2102 has been marked as a duplicate of this bug. ***

@matthijskooijman
Copy link
Mannequin

matthijskooijman mannequin commented Jun 20, 2008

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’

@matthijskooijman
Copy link
Mannequin

matthijskooijman mannequin commented Jun 20, 2008

@asl
Copy link
Collaborator

asl commented Sep 10, 2008

*** Bug llvm/llvm-bugzilla-archive#2785 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 11, 2008

Is there any workaround for this issue? Thanks.

-Arif

@asl
Copy link
Collaborator

asl commented Sep 11, 2008

Is there any workaround for this issue? Thanks.
Yes, surely. Don't use inline asm :)

@asl
Copy link
Collaborator

asl commented Sep 29, 2008

*** Bug llvm/llvm-bugzilla-archive#2839 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented May 20, 2009

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

@asl
Copy link
Collaborator

asl commented Sep 8, 2009

*** Bug llvm/llvm-bugzilla-archive#4924 has been marked as a duplicate of this bug. ***

@asl
Copy link
Collaborator

asl commented Dec 25, 2009

*** Bug llvm/llvm-bugzilla-archive#5877 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 2, 2011

CBE patch
Attached patch fixes some of these issues. I sent this to llvm-commits but I guess I should've searched the bug tracker to see if anyone else came across this earlier.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 15, 2011

Created an attachment (id=6093) [details]
CBE patch

Attached patch fixes some of these issues. I sent this to llvm-commits but I
guess I should've searched the bug tracker to see if anyone else came across
this earlier.

Ping?
Would it be possible to commit this?

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 15, 2011

Could you please add some testcases.

@lattner
Copy link
Collaborator Author

lattner commented Apr 16, 2011

*** Bug llvm/llvm-bugzilla-archive#9737 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 16, 2011

Could you please add some testcases.

The patch from Jai Menon fixes the case from bug 9737 http://llvm.org/bugs/show_bug.cgi?id=9737

Instead of invalid inline asm

asm volatile ("rorw %%8, %w0"
:"=r"(llvm_cbe_asmtmp)
:"0"(((unsigned short )15))"cc");

patched CBE generates

asm volatile ("rorw $8, %w0"
:"=r"(llvm_cbe_asmtmp)
:"0"(((unsigned short )15))
:"cc");

and result is correct. Checked with llvm trunk r129558.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 16, 2011

However, there are still fails with

Assertion `I->Codes.size() == 1 && "Too many asm constraint codes to handle"' failed.

So patch fixes only the issue specific to inline asm arguments, and to fix the assertion above somebody should implement

//TODO: work out platform independent constraints and factor those out
// of the per target tables
// handle multiple constraint codes

@d0k
Copy link
Member

d0k commented Mar 26, 2012

The C backend was removed from svn trunk and is no longer maintained. Closing the bug.

@asl
Copy link
Collaborator

asl commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#862

@lattner
Copy link
Collaborator Author

lattner commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#9737

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@Quuxplusone Quuxplusone added the wontfix Resolved as "WON'T FIX." Not "INVALID" — the issue is real, but we can't or won't fix it label Jan 20, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla missing-feature Feature requests? Is this different from [enhancement]? wontfix Resolved as "WON'T FIX." Not "INVALID" — the issue is real, but we can't or won't fix it
Projects
None yet
Development

No branches or pull requests

5 participants