bugpoint / cbe Problems

I'm having some trouble using bugpoint with newer version of gcc (bugpoint
debug output below).

I looked into the "conflicting type for malloc" problem and it doesn't seem
easy to solve due to the unknown size of size_t (see LowerAllocations.cpp).

The "void main()" problem is probably a result of this test being converted
from Fortran. I'll have to dig into that some more.

The missing ";" looks like a serious problem. The CBE is just generating
bogus code:

llvm_cbe_file_20_test_2e_f_2c__20_line_20_151_2c__20_bb66:
  llvm_cbe_r1380 = *(&llvm_cbe_SUM);
  *(&llvm_cbe__24_SUM_S94) = llvm_cbe_r1380;
  llvm_cbe_r1381 = *(&llvm_cbe__24_SUM_S94);
  return llvm_cbe_r1381
<EOF>

That is, there's no semicolon and no closing brace.

Is anyone else seeing these kinds of problems?

                                                           -Dave

Bugpoint debug output:

Generating reference output from raw program: <cbe>
About to run: /ptmp/dag/universal_build/llvm-project/Debug/bin/llc -o
bugpoint-test-program.bc.cbe.c -march=c -f bugpoint-test-program.bc
<cbe>
About to run: /ptmp/dag/universal_build/llvm-project/Debug/bin/llc -o
bugpoint-test-program.bc.cbe.c -march=c -f bugpoint-test-program.bc
<cray>
About to run: /usr/bin/gcc bugpoint-test-program.bc.cbe.c -c -o
bugpoint-test-program.bc.cbe.c.cray.o

Error running tool:
  /usr/bin/gcc bugpoint-test-program.bc.cbe.c -c -o
bugpoint-test-program.bc.cbe.c.cray.o
bugpoint-test-program.bc.cbe.c:235: warning: conflicting types for built-in
function 'malloc'
bugpoint-test-program.bc.cbe.c: In function 'main':
bugpoint-test-program.bc.cbe.c:407: warning: return type of 'main' is not
'int'
bugpoint-test-program.bc.cbe.c:7267:24: warning: no newline at end of file
bugpoint-test-program.bc.cbe.c: In function 'vlswork_':
bugpoint-test-program.bc.cbe.c:7267: error: expected ';' at end of input
bugpoint-test-program.bc.cbe.c:7267: error: expected declaration or statement
at end of input

I was using gcc 4.1.2. When I try 3.2.3 I get:

bugpoint-test-program.bc.cbe.c:237: warning: conflicting types for built-in
function `memcpy'
bugpoint-test-program.bc.cbe.c: In function `main':
bugpoint-test-program.bc.cbe.c:581: no vector mode with the size and type
specified could be found

and a bunch more vector errors.

So I'm in a bit of a pickle. Does anyone know which versions of gcc
understand the cbe output?

                                                -Dave

After hacking around in the CBE output I managed to compile it with
gcc, only to discover that gcc 4.1.2 has the SAME bug LLVM does with
respect to alignment. It is using a movapd where the address is NOT
aligned. So I can't generate correct code using CBE/gcc. Our C compiler
doesn't recognize gcc's vector intrinsics so I can't use CBE with that.

I discovered that I can reproduce the problem with:

/ptmp/dag/universal_build/llvm-project/Debug/bin/opt -std-compile-opts -f -o
bugpoint-test-program.opt.bc bugpoint-test-program.bc
/ptmp/dag/universal_build/llvm-project/Debug/bin/llc -f -o
bugpoint-test-program.opt.bc.s bugpoint-test-program.opt.bc
ftn bugpoint-test-program.opt.bc.s (our Fortran compiler)
./a.out

If I remove -std-compile-opts, it passes.

I don't see a way to run opt directly with bugpoint. It seems to want to go
through the CBE, which has the problems I mentioned before (generating
syntactically-incorrect C).

If I pass -run-llc to bugpoint it seems to ignore optimization flags I give
it. Only running bugpoint with default options (which seems to be the
same as -run-cbe) seems to accept optimization flags.

What's the proper incantation to get bugpoint to run things through opt
but use llc to generate asm? As noted, CBE has issues generating
correct code so using it isn't an option right now.

                                                  -Dave

It should be something like bugpoint x.bc -llc-safe -pass1 -pass2
-pass3. The -llc-safe forces it to never use CBE.

-Eli

Yep, that works. It's happily chewing away now! Thanks!

                                                 -Dave