[LLVMdev] Bug in optimization pass related to strcmp and bigendian back-ends
Nick Lewycky
nicholas at mxc.ca
Tue Aug 11 19:34:31 PDT 2009
Stripf, Timo wrote:
> I thought the LLVM IR is target independent
Yes.
and that "llvm-gcc -c -emit-llvm -O2" produces target independent code.
No.
> I'm working on a back-end and use llvm-gcc to first generate the bc file. Afterwards I use llc including the new back-end to produce the assembler file.
LLVM IR contains a target-information line but is otherwise target
independent. This does *not* mean that you can convert C to LLVM IR in a
target independent way.
C code may contain "#ifdef __ppc__". Now what? Or how about "switch (x)
{ case sizeof(int): ... }". This question is a FAQ:
http://llvm.org/docs/FAQ.html#platformindependent
LLVM IR is portable in the sense that it will run the same on any
platform. C is portable in the sense that you can detect things about
the platform so you may correct for them. It turns out that these are
two fundamentally incompatible paradigms.
Some LLVM optimizations take advantage of the information in the target
info line which could change the behaviour of the program if your target
system doesn't match the one described in the info line.
Nick
More information about the llvm-dev
mailing list