I'm wondering what the longer term plans are for the C Backend. I understand it's not actively developed, even deprecated. What I'm not clear about is whether it's something that is viewed as non-vital and should just as well go away, or if it's just a low priority. Basically: it's not improving, but is it likely to disappear?
I don't know of anyone actively working on it, and that means it isn't likely to improve anytime soon.
That said, a saving grace of the C backend is that it is very isolated from the rest of the compiler. That means that there is little reason to rip it out. However, as new features are added to LLVM IR, the C backend *is* likely to get more and more out of date and less and less useful.
In short, I don't see a compelling reason to rip it out anytime soon. If it ends up being completely broken for simple programs, it might make sense to remove in the future.
I'm wondering what the longer term plans are for the C Backend. I
understand it's not actively developed, even deprecated. What I'm not
clear about is whether it's something that is viewed as non-vital and
should just as well go away, or if it's just a low
priority. Basically: it's not improving, but is it likely to
disappear?
I don't know of anyone actively working on it, and that means it isn't likely to improve anytime soon.
I have quite a few patches for it queued up. Vector code is a problem
since the C backend currently generates aligned vector loads of
unaligned data.
In short, I don't see a compelling reason to rip it out anytime soon.
If it ends up being completely broken for simple programs, it might
make sense to remove in the future.
There's a big reason to keep it. It's a godsend when trying to bugpoint
something where no working llc is available. I've used it quite a lot
during AVX development, for example. It's useful for developing any
new target.
I'm wondering what the longer term plans are for the C Backend. I
understand it's not actively developed, even deprecated. What I'm not
clear about is whether it's something that is viewed as non-vital and
should just as well go away, or if it's just a low
priority. Basically: it's not improving, but is it likely to
disappear?
I don't know of anyone actively working on it, and that means it isn't likely to improve anytime soon.
I have quite a few patches for it queued up. Vector code is a problem
since the C backend currently generates aligned vector loads of
unaligned data.
In short, I don't see a compelling reason to rip it out anytime soon.
If it ends up being completely broken for simple programs, it might
make sense to remove in the future.
There's a big reason to keep it. It's a godsend when trying to bugpoint
something where no working llc is available. I've used it quite a lot
during AVX development, for example. It's useful for developing any
new target.
an alternative is to make the interpreter more powerful and have bugpoint
use it rather than the C backend.
You need to set attribute ReadOnly on the sin / cos functions, using Function::addFnAttr(Attribute) for example.
the readnone attribute means that the function doesn't dereference any pointers,
doesn't read any global variables etc; while readonly means that while the
function can dereference pointers, it only reads memory and doesn't write it.
Declaring something readnone is stronger than declaring it readonly.
If sin and cos do not write to errno (or you want to ignore that they write to
errno) then you can declare them readonly. If they also don't depend on the
floating point rounding mode (which is modelled as a global variable in LLVM)
or you don't care about rounding modes, then you can declare them readnone.
I've copied the code as-is from http://llvm.org/docs/tutorial/LangImpl4.html#code and added "F->addFnAttr( Attribute::ReadOnly )" after "Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule)".
The passes it sets up are:
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));
// Do simple "peephole" optimizations and bit-twiddling optzns.
OurFPM.add(createInstructionCombiningPass());
// Reassociate expressions.
OurFPM.add(createReassociatePass());
// Eliminate Common SubExpressions.
OurFPM.add(createGVNPass());
// Simplify the control flow graph (deleting unreachable blocks, etc).
OurFPM.add(createCFGSimplificationPass());
if you are using LLVM from svn then you need to specify the basic-aa analysis,
otherwise gvn won't unify calls to readonly/readnone functions. This is new
behaviour introduced by Dan; probably the tutorial should be updated.
There's a big reason to keep it. It's a godsend when trying to bugpoint
something where no working llc is available. I've used it quite a lot
during AVX development, for example. It's useful for developing any
new target.
an alternative is to make the interpreter more powerful and have bugpoint
use it rather than the C backend.
That would actually be better. I've never tried the interpreter. Do
you have a sense of what's needed to make it more powerful?
There's a big reason to keep it. It's a godsend when trying to bugpoint
something where no working llc is available. I've used it quite a lot
during AVX development, for example. It's useful for developing any
new target.
an alternative is to make the interpreter more powerful and have bugpoint
use it rather than the C backend.
That would actually be better. I've never tried the interpreter. Do
you have a sense of what's needed to make it more powerful?
Are you sure that this is a good idea? The interpreter (if it is made to work) will probably be much, much slower than the C backend.
Since both the interpreter and the CBE need some love and care to work again, it may be better to exert effort on the CBE.
If anyone was really interested in this, I'd strongly suggest a complete rewrite of the C backend: make use the existing target independent code generator code (for legalization etc) and then just put out a weird ".s file" at the end.
IMHO, we should keep the C backend. It still has value, in particular
someone may come along and fix it up. I agree with Chris' earlier
point that there is little value in ripping it out, aside from users
being confused when it doesn't work.