Experimental fixes to CBackend


LLVM C backend as of revision 136600 suffers from the following issues:

* Forward structs declarations block is missing (it was there
previously, why was it removed?)
* Anonymous container structs are not generated for array types,
resulting into declarations being placed directly into functions
prototypes (previously it was not happening as well)

I'm not very familiar with llvm internals, but tried by best to fix
the problems. Please see proposed patches in attachment. Briefly, I'm
creating fictive StructType for each ArrayType and slightly changing
logic of anonymous structs definition to account the special case of

- D.

llvm.patch (5.03 KB)


Please see the collection of test cases attached. To build everything
execute make in the top directory. Files with logs show how
compilation fails/succeeds, depending on patched/unpatched version of

Could we setup this test suite as a regular test for C backend?

- D.

cbe_tests.tar.gz (32.9 KB)

The patch seems sane, although I'm not an expert in how the C backend
works. Please include some regression tests using FileCheck in
test/CodeGen/CBackend. (While you're at it, rewriting some of the
existing tests to actually check their output would be a good idea.)


We really don't have a particularly good place in the existing test
infrastructure for testing the C backend... and there's generally low
interest in it. If you have a use for the C backend, I would suggest
making sure there are quality regression tests in
test/CodeGen/CBackend (so things don't accidentally break), and
regularly testing your uses yourself.


Hi Eli,

Thanks for directions!

and regularly testing your uses yourself.

Well, that's what I'm in fact already doing for a while. OK, I will
look into test/CodeGen/CBackend, probably I should align my test suite
with this standard one.

- D.