I just checked in an important change to the LLVM Verifier pass, and have
compiled a new version of the GCC front-end. The big change is that we
now match the LangRef.html much more closely: many operations on pointer
operands are illegal.
Essentially, the GCC front-end should never generate adds, subtracts,
multiplies, divides, rem, or shr/shl instructions that take pointer
operands now. In order to do one of these operations, it must now cast
to ulong, perform the operation, then cast back to a pointer type.
I should have done this long ago, because allowing pointers in these
instructions allows all kinds of unusual bugs
(http://mail.cs.uiuc.edu/pipermail/llvm-commits/2002-September/000077.html)
to crop up. Now that they are gone, we can slowly remove the special code
that was implemented to handle them, and future code won't need it.
In addition, LLVM is now to the point where the only way to write
type-unsafe code is with the cast instruction. This has been a goal for a
long time, and we talk a lot about it in papers, so we really should do
what we say. :)
As part of the conversion process, the Verifier pass has been updated to
check the operand constraints of the instructions in question:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/2002-September/000089.html
Vikram: If you update the CSIL LLVM repository without updating the CSIL
GCC frontend, you will have problems. You can update the GCC frontend
without updating the LLVM tree, but not visa-versa.
There are some performance regressions in the generated code now because
the level raise pass doesn't handle the extra casts in all cases it
should. Depending on priorities and the amount of time it would take, I
may go ahead and fix this soon, or I might just incorporate the fixes in
the (much faster and smarter) replacement level raise pass that I'm
working on periodically.
The only other problems that this may cause is w.r.t testcases in the
test/ directory. If a testcase does bad pointer stuff it will fail to
compile correctly (because the verifier will reject it), and presumably
the testcase will fail. In these cases the testcases need to be updated.
If you notice any tests doing this, let me know and I'll fix them.
Hopefully this change will make everyones lives easier. If you run into
any problems, let me know.
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/