[llvm-commits] [PATCH] Rotate CallInst operands -- HEADS UP

Gabor Greif gabor at mac.com
Tue Apr 13 08:50:22 PDT 2010


Hi all,

I am about to submit a patch for reordering CallInst operands.

Note: this potentially will have an effect on any optimizer that
does not use CallSite + getCalledValue (the abstract interface)
but does getOperand/setOperand on the CallInst directly.

In a nutshell, the "callee" operand moves to the last operand
position, whereas it used to reside in the frontmost position.

Motivation ---------------------------------------------------
Because of the internal workings of Use::getUser() the operands
near the end of the operand array allow a faster access to their
User. Call-Graph computation relies on getUser() and is expected
to become speedier.
Also, InvokeInst already has transitioned to this operand ordering
some time ago (already in the upcoming release 2.7). Moving CallInst
over allows to simplify CallSite.
Third, there is no more need to add 1 to op_begin() when accessing
the arguments of the call.
Fourth, getCalledValue (and friends) now access a value at a constant
offset from the CallInst, whereas before this change it needed a pointer
dereference operation (resp. a multiplication with sizeof(Use)).

What to do ---------------------------------------------------

If you have an optimization framework that interrogates CallInsts
directly, you should use the abstract accessors CallSite and
getCalledValue/Function (and friends) so you don't have to bother
with operand positioning. You can make these changes (to employ
the abstract accessors) now, and this will probably improve your
code because they also handle InvokeInst.

llvm-gcc needed no adjustment, and clang needed one change (in the
spirit of the lines above) which has been checked in already.

For reviewers -------------------------------------------------

The changes are mostly mechanical, and do not need a lot of explanation.
There is at least one fix to an InvokeInst bug (in CBackend). Of
course I could commit that (those) separately.

Cheers,

	Gabor


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CallInst-r101132.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100413/ff6e840c/attachment.ksh>


More information about the llvm-commits mailing list